Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot plot Cone that is a halfplane in 2d #25114

Open
yuan-zhou opened this issue Apr 6, 2018 · 13 comments
Open

Cannot plot Cone that is a halfplane in 2d #25114

yuan-zhou opened this issue Apr 6, 2018 · 13 comments

Comments

@yuan-zhou
Copy link

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

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

CC: @novoselt @jplab @mkoeppe @orlitzky

Component: geometry

Keywords: Cone, plot, IMA-PolyGeom

Branch/Commit: u/yzh/cannot_plot_cone_that_is_a_halfplane_in_2d @ 57f5898

Issue created by migration from https://trac.sagemath.org/ticket/25114

@yuan-zhou yuan-zhou added this to the sage-8.2 milestone Apr 6, 2018
@yuan-zhou
Copy link
Author

@yuan-zhou
Copy link
Author

New commits:

959187frepresent the rays of wall by a matrix. add doctest

@yuan-zhou
Copy link
Author

Commit: 959187f

@yuan-zhou
Copy link
Author

Changed keywords from Cone, plot to Cone, plot, IMA-PolyGeom

@novoselt
Copy link
Member

novoselt commented Apr 7, 2018

comment:3

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.

@jplab
Copy link

jplab commented Mar 1, 2020

comment:4

Replying to @novoselt:

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...

@mkoeppe
Copy link
Member

mkoeppe commented Apr 14, 2020

comment:5

pushing these forward to 9.2

@mkoeppe mkoeppe modified the milestones: sage-8.2, sage-9.2 Apr 14, 2020
@mkoeppe mkoeppe modified the milestones: sage-9.2, sage-9.3 Sep 5, 2020
@mkoeppe
Copy link
Member

mkoeppe commented Feb 13, 2021

comment:8

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

@mkoeppe mkoeppe modified the milestones: sage-9.3, sage-9.4 Feb 13, 2021
@yuan-zhou
Copy link
Author

comment:9

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.

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Mar 25, 2021

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

57f5898Merge branch 'develop' of git://trac.sagemath.org/sage into HEAD

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Mar 25, 2021

Changed commit from 959187f to 57f5898

@orlitzky
Copy link
Contributor

comment:11

Replying to @yuan-zhou:

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

@mkoeppe
Copy link
Member

mkoeppe commented Jul 19, 2021

comment:12

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

@mkoeppe mkoeppe modified the milestones: sage-9.4, sage-9.5 Jul 19, 2021
@mkoeppe mkoeppe modified the milestones: sage-9.5, sage-9.6 Dec 18, 2021
@mkoeppe mkoeppe modified the milestones: sage-9.6, sage-9.7 Apr 17, 2022
@mkoeppe mkoeppe modified the milestones: sage-9.7, sage-9.8 Aug 31, 2022
@mkoeppe mkoeppe removed this from the sage-9.8 milestone Jan 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants