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

Parents for polyhedra #11763

Closed
vbraun opened this issue Aug 31, 2011 · 87 comments
Closed

Parents for polyhedra #11763

vbraun opened this issue Aug 31, 2011 · 87 comments

Comments

@vbraun
Copy link
Member

vbraun commented Aug 31, 2011

The Polyhedron class is, so far, free-standing with some sort of coercion for the base ring tacked manually. This ticket strives to add parents for polyhedra and make the base ring coercion work more naturally.

There will be 3 supported base rings:

  • ZZ (meaning that the polyhedron is a lattice polytope, that is, both H- and V-representation are defined over ZZ)
  • QQ
  • RDF

Apply:

Depends on #11634
Depends on #13109
Depends on #11310

CC: @robertwb

Component: geometry

Author: Volker Braun

Reviewer: Dmitrii Pasechnik

Merged: sage-5.6.beta1

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

@novoselt
Copy link
Member

comment:1

Would there be any benefit in supporting real fields of arbitrary precision?

@vbraun
Copy link
Member Author

vbraun commented Aug 31, 2011

comment:2

We don't have an implementation of the double description algorithm for other base rings, so we wouldn't be able to compute anything.

@vbraun
Copy link
Member Author

vbraun commented Sep 8, 2011

Attachment: trac_11763_ZZ_polyhedron.patch.gz

Initial patch

@vbraun
Copy link
Member Author

vbraun commented Sep 8, 2011

Initial patch

@vbraun

This comment has been minimized.

@vbraun
Copy link
Member Author

vbraun commented Sep 8, 2011

comment:3

Attachment: trac_11763_parents_for_polyhedron.py.gz

This is now ready for inclusion. Marshall, are you interested in reviewing this patch and its dependency? ;-)

@vbraun
Copy link
Member Author

vbraun commented Sep 8, 2011

Author: Volker Braun

@vbraun

This comment has been minimized.

@vbraun
Copy link
Member Author

vbraun commented Feb 19, 2012

comment:5

Fix comparison of H/V-representation objects:

sage: triangle = Polyhedron([(0,0), (1,0), (0,1)])
sage: ieq = triangle.inequality_generator().next()
sage: ieq == copy(ieq)
False

Now returns True, as it should.

@vbraun
Copy link
Member Author

vbraun commented Feb 19, 2012

Updated patch

@loefflerd
Copy link
Mannequin

loefflerd mannequin commented Mar 11, 2012

Attachment: trac_11763_parents_for_polyhedron.patch.gz

Attachment: trac_11763_ZZ_polyhedron-rebase.patch.gz

Rebased for new patch at 11634

@loefflerd
Copy link
Mannequin

loefflerd mannequin commented Mar 11, 2012

Attachment: trac_11763_parents-rebase.patch.gz

Rebased for new patch at #11634

@loefflerd
Copy link
Mannequin

loefflerd mannequin commented Mar 11, 2012

comment:6

The new patch I posted at #11634 broke these, so I rebased them.

Apply trac_11763_ZZ_polyhedron-rebase.patch, trac_11763_parents-rebase.patch

@loefflerd

This comment has been minimized.

@loefflerd
Copy link
Mannequin

loefflerd mannequin commented Mar 11, 2012

comment:7

Apply trac_11763_zz_polyhedron-rebase.patch, trac_11763_parents-rebase.patch

(bloody patchbot!)

@loefflerd
Copy link
Mannequin

loefflerd mannequin commented Mar 11, 2012

comment:8

No matter what I do, the patchbot won't pick up the two patches above, so I've done a single qfolded patch. Hopefully this will now work!

@loefflerd

This comment has been minimized.

@loefflerd
Copy link
Mannequin

loefflerd mannequin commented Mar 12, 2012

Apply only this patch. Patch against 5.0.beta7

@loefflerd
Copy link
Mannequin

loefflerd mannequin commented Mar 12, 2012

comment:10

Attachment: trac_11763-polyhedra_coercion_folded.patch.gz

Sorry, I made a hash of rebasing the patch, so here's a new version.

@sagetrac-mhampton
Copy link
Mannequin

sagetrac-mhampton mannequin commented Mar 12, 2012

comment:11

This changes the behavior of the .vertices() method, returning "sage.geometry.polyhedron.representation.Vertex" objects instead of simple lists of coordinates. This breaks some code of mine, so I think there should be a deprecation warning before introducing this. I don't really like the behavior, but I see that .vertices_list() does return a list of lists of coordinates.

This patch also seems to slow things down a bit, but I haven't carefully tested that aspect.

@vbraun
Copy link
Member Author

vbraun commented Mar 12, 2012

comment:12

The Vertex object implements the list interface, so any code that doesn't just test isinstance(-,list) should work fine. Plus, you can't really deprecate something unless you want to remove it later. I added the 'vertices_list` method so people can keep their broken code with minimal patching if they want.

@sagetrac-mhampton
Copy link
Mannequin

sagetrac-mhampton mannequin commented Mar 12, 2012

comment:13

Well, no, there is quite a bit of my code that does not work fine, and I am not talking about artificial test cases. Here is a shortened example of something this patch breaks:

c = polytopes.n_cube(3)
v = c.vertices()[0]
point(v)

This now gives a "TypeError: 'sage.rings.integer.Integer' object does not support indexing".

@novoselt
Copy link
Member

comment:14

For the record: #12541 and #12544 have a similar situation. I replaced tuples with tuple-like containers and some stuff got broken. As it turned out, it was not too difficult to fix it by eliminating some "hard typechecks", although they are still waiting for an approval. If this is the case here, perhaps it is also not too difficult to fix.

As I understand it, direct typechecking is not welcomed in either Python or Sage, so if the new class implements list interface, it should be OK to use in place of the old one. If it does break some code, it is a bug and it should be fixed before merging, but not a reason for avoiding the change entirely or inventing elaborate deprecation scheme...

@loefflerd
Copy link
Mannequin

loefflerd mannequin commented Mar 26, 2012

comment:15

There is a doctest failing on 5.0.beta10, according to the patchbot (something to do with the new associahedron class from #10817)

@vbraun
Copy link
Member Author

vbraun commented Nov 27, 2012

comment:50

For the patchbot:

Apply trac_11763-polyhedra_coercion_folded.2.patch, trac_11763_fix_associahedron.patch, trac_11763_lazy_import.patch

@vbraun
Copy link
Member Author

vbraun commented Nov 28, 2012

Reviewer: Dmitrii Pasechnik

@jdemeyer
Copy link

comment:52

On some systems, such as OS X >= 10.6 and Itanium:

sage -t  --long -force_lib devel/sage/sage/geometry/polyhedron/base.py
**********************************************************************
File "/Users/dehayebuildbot/build/sage/dehaye/dehaye_full/build/sage-5.6.beta0/devel/sage-main/sage/geometry/polyhedron/base.py", line 385:
    sage: cmp(P, 'string')
Expected:
    -1
Got:
    1
**********************************************************************

@vbraun
Copy link
Member Author

vbraun commented Dec 18, 2012

Attachment: trac_11763-polyhedra_coercion_folded.2.patch.gz

Updated patch

@vbraun
Copy link
Member Author

vbraun commented Dec 18, 2012

comment:54

I've added the trivial fix.

@vbraun
Copy link
Member Author

vbraun commented Dec 18, 2012

comment:55

And now I noticed that this was already fixed in #12193.

@jdemeyer
Copy link

Merged: sage-5.6.beta1

@jdemeyer
Copy link

@jdemeyer

This comment has been minimized.

@jdemeyer
Copy link

comment:57

Rebased to sage-5.6.beta0.

@novoselt
Copy link
Member

comment:58

Hey Volker,

Do you remember what was the reason for this change in normalize_rays?

diff --git a/sage/geometry/cone.py b/sage/geometry/cone.py

Index: sage/geometry/cone.py
===================================================================
--- a/sage/geometry/cone.py
+++ b/sage/geometry/cone.py
@@ -568,7 +568,10 @@
         V = lattice.base_extend(QQ)
         for n, ray in enumerate(rays):
             try:
-                ray = V(ray)
+                if isinstance(ray, (list, tuple, V._element_class)):
+                    ray = V(ray)
+                else:
+                    ray = V(list(ray))
             except TypeError:
                 raise TypeError("cannot convert %s to %s!" % (ray, V))
             if ray.is_zero():

It seems that if V does not want to take a ray, we should not force it.

@vbraun
Copy link
Member Author

vbraun commented Dec 24, 2012

comment:59

I think the idea is to allow arbitrary iterables in normalize_rays. Why not? Its an auxiliary function, and the more general it is the better.

@novoselt
Copy link
Member

comment:60

I just was wondering what was the particular use case - found this bit because of the fuzz with another patch. I don't mind it, although changing what V.__call__ accepts seems a more pleasant solution ;-)

@vbraun
Copy link
Member Author

vbraun commented Dec 25, 2012

comment:61

Replying to @novoselt:

I don't mind it, although changing what V.__call__ accepts seems a more pleasant solution ;-)

Wasn't that one of our design decisions, that the ToricLattice should forbid conversion between the lattice and its dual?

@novoselt
Copy link
Member

comment:62

Replying to @vbraun:

Wasn't that one of our design decisions, that the ToricLattice should forbid conversion between the lattice and its dual?

We prohibit coercion, conversion is certainly possible, and here V is the spanned vector space anyway. But I've also hit many times a situation when a standard constructor in Sage would not take generators as input, which is probably what has happened here.

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