Opened 4 years ago

# Cannot plot Cone that is a halfplane in 2d

Reported by: Owned by: yzh major sage-9.7 geometry Cone, plot, IMA-PolyGeom novoselt, jipilab, mkoeppe, mjo N/A u/yzh/cannot_plot_cone_that_is_a_halfplane_in_2d 57f5898581472100027da43f1a34b5427c9f3d84

### Description

```sage: halfplane = Cone([(1,0), (0,1), (-1,0)])
sage: halfplane.plot()
```

raises `UnboundLocalError`: local variable 'r1' referenced before assignment.

### comment:1 Changed 4 years ago by yzh

• Branch set to u/yzh/cannot_plot_cone_that_is_a_halfplane_in_2d

### comment:2 Changed 4 years ago by yzh

• Cc jipilab mkoeppe added
• Commit set to 959187fab39c01a62f9c3389a238b48c58e95b77
• Keywords IMA-PolyGeom added
• Status changed from new to needs_review

New commits:

 ​959187f `represent the rays of wall by a matrix. add doctest`

### comment:3 follow-up: ↓ 4 Changed 4 years ago by novoselt

• Status changed from needs_review to needs_work

While this may fix the plotting issue, it hides the real problem:

```sage: N = ToricLattice(2); N
2-d lattice N
sage: NQ = N.base_extend(QQ); NQ
Vector space of dimension 2 over Rational Field
sage: r = N.gen(0); r
N(1, 0)
sage: S = N.submodule([r]); S
Sublattice <N(1, 0)>
sage: SQ = S.base_extend(QQ); SQ

Vector space of degree 2 and dimension 1 over Rational Field
Basis matrix:
[1 0]
sage: r in N, r in NQ
(True, True)
sage: r in S, r in SQ
(True, False)
```

Why is there this difference in behaviour of vector spaces and subspaces? The original code likely worked for halfplanes when it was written and there is no reason for it to stop.

### comment:4 in reply to: ↑ 3 Changed 2 years ago by jipilab

While this may fix the plotting issue, it hides the real problem:

```sage: N = ToricLattice(2); N
2-d lattice N
sage: NQ = N.base_extend(QQ); NQ
Vector space of dimension 2 over Rational Field
sage: r = N.gen(0); r
N(1, 0)
sage: S = N.submodule([r]); S
Sublattice <N(1, 0)>
sage: SQ = S.base_extend(QQ); SQ

Vector space of degree 2 and dimension 1 over Rational Field
Basis matrix:
[1 0]
sage: r in N, r in NQ
(True, True)
sage: r in S, r in SQ
(True, False)
```

Why is there this difference in behaviour of vector spaces and subspaces? The original code likely worked for halfplanes when it was written and there is no reason for it to stop.

Looking at the file `src/sage/structure/parent.pyx` in the `__contains__` function, it returns `False` because:

```sage: type(r)
<class 'sage.geometry.toric_lattice_element.ToricLatticeElement'>
sage: r2 = SQ(r); r2
(1, 0)
sage: type(r2)
<class 'sage.modules.vector_rational_dense.Vector_rational_dense'>
```

and

```sage: r2 == r
False
```

Now, should this return `True`? I am not sure how to fix this...

### comment:5 Changed 2 years ago by mkoeppe

• Milestone changed from sage-8.2 to sage-9.2

pushing these forward to 9.2

### comment:6 Changed 22 months ago by mkoeppe

• Milestone changed from sage-9.2 to sage-9.3

• Cc mjo added

### comment:8 Changed 17 months ago by mkoeppe

• Milestone changed from sage-9.3 to sage-9.4

Setting new milestone based on a cursory review of ticket status, priority, and last modification date.

### comment:9 follow-up: ↓ 11 Changed 16 months ago by yzh

Is it possible to make the plotting work at least? It's a bit annoying to have encountered this same error after each reinstallation of Sage.

### comment:10 Changed 16 months ago by git

• Commit changed from 959187fab39c01a62f9c3389a238b48c58e95b77 to 57f5898581472100027da43f1a34b5427c9f3d84

Branch pushed to git repo; I updated commit sha1. New commits:

 ​57f5898 `Merge branch 'develop' of git://trac.sagemath.org/sage into HEAD`

### comment:11 in reply to: ↑ 9 Changed 16 months ago by mjo

Is it possible to make the plotting work at least? It's a bit annoying to have encountered this same error after each reinstallation of Sage.

I was juuuust about to agree with you. But the underlying problem here is serious. Equality is not transitive:

```sage: N = ToricLattice(2)
sage: NQ = N.base_extend(QQ)
sage: r = N.gen(0)
sage: S = N.submodule([r])
sage: SQ = S.base_extend(QQ)
sage: r == S(r)
True
sage: S(r) == SQ(r)
True
sage: r == SQ(r)
False
```

### comment:12 Changed 12 months ago by mkoeppe

• Milestone changed from sage-9.4 to sage-9.5

Setting a new milestone for this ticket based on a cursory review.

### comment:13 Changed 7 months ago by mkoeppe

• Milestone changed from sage-9.5 to sage-9.6

### comment:14 Changed 3 months ago by mkoeppe

• Milestone changed from sage-9.6 to sage-9.7
Note: See TracTickets for help on using tickets.