Opened 3 years ago
Last modified 3 months ago
#25114 needs_work defect
Cannot plot Cone that is a halfplane in 2d
Reported by:  yzh  Owned by:  

Priority:  major  Milestone:  sage9.4 
Component:  geometry  Keywords:  Cone, plot, IMAPolyGeom 
Cc:  novoselt, jipilab, mkoeppe, mjo  Merged in:  
Authors:  Reviewers:  
Report Upstream:  N/A  Work issues:  
Branch:  u/yzh/cannot_plot_cone_that_is_a_halfplane_in_2d (Commits, GitHub, GitLab)  Commit:  57f5898581472100027da43f1a34b5427c9f3d84 
Dependencies:  Stopgaps: 
Description
sage: halfplane = Cone([(1,0), (0,1), (1,0)]) sage: halfplane.plot()
raises UnboundLocalError
: local variable 'r1' referenced before assignment.
Change History (11)
comment:1 Changed 3 years ago by
 Branch set to u/yzh/cannot_plot_cone_that_is_a_halfplane_in_2d
comment:2 Changed 3 years ago by
 Cc jipilab mkoeppe added
 Commit set to 959187fab39c01a62f9c3389a238b48c58e95b77
 Keywords IMAPolyGeom added
 Status changed from new to needs_review
comment:3 followup: ↓ 4 Changed 3 years ago by
 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 2d 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 16 months ago by
Replying to novoselt:
While this may fix the plotting issue, it hides the real problem:
sage: N = ToricLattice(2); N 2d 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 14 months ago by
 Milestone changed from sage8.2 to sage9.2
pushing these forward to 9.2
comment:6 Changed 10 months ago by
 Milestone changed from sage9.2 to sage9.3
comment:7 Changed 9 months ago by
 Cc mjo added
comment:8 Changed 4 months ago by
 Milestone changed from sage9.3 to sage9.4
Setting new milestone based on a cursory review of ticket status, priority, and last modification date.
comment:9 followup: ↓ 11 Changed 3 months ago by
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 3 months ago by
 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 3 months ago by
Replying to 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.
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
New commits:
represent the rays of wall by a matrix. add doctest