sagemath / sage

Main repository of SageMath
https://www.sagemath.org
Other
1.44k stars 481 forks source link

A lot of polytope constructors are broken #18213

Closed videlec closed 9 years ago

videlec commented 9 years ago

A lot of polytopes constructors in sage.geometry.polyhedron.library. For example

  1. The Rhombicuboctahedron does not return what it should (as Python division was thought as Sage integer divisions). There is in the code
verts = [ [-3/2, -1/2, -1/2], [-3/2, -1/2, 1/2], [-3/2, 1/2, -1/2],
...
  1. The great_rhombicuboctahedron is defined over QQ but it should be defined over QQ[sqrt(2)]! There are in two places rough approximation of sqrt(2) in the code
v1 = QQ(131739771357/54568400000)   # ~ sqrt(2) + 1 but actually 2 due to Python division
v2 = QQ(104455571357/27284200000)   # ~ 2 sqrt(2) but actually 3 due to Python division

Instead, we should use the base_ring argument (with appropriate defaults) and use base_ring(2).sqrt() instead.

  1. The functions unrelated to construction of Polytopes are moved out of the class Polytopes:
    • Polytopes.orthonormal_1, Polytopes.project_1 will be renamed respectively zero_sum_projection and project_points
    • the one line Polytopes._pfunc is just removed

While we're at it, remove the deprecations from #11634.

During the process I discovered two annoying bugs:

Depends on #18211

CC: @nathanncohen

Component: geometry

Author: Vincent Delecroix

Branch/Commit: a58da00

Reviewer: Nathann Cohen

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

6bdad4c1-1e26-4f2f-a442-a01a2292c181 commented 9 years ago
comment:39

Okayyyyyyyyyyyyyy. End of the review. Nothing else to add ;-)

Very good job. This code needed to be cleaned, and it is much better now.

But please, next time: smaller patches. You waste your reviewers' health :-P

Nathann

videlec commented 9 years ago
comment:40

Replying to @nathanncohen:

HMmmmmmmm... I don't exactly know what the isometry group is, but let's try anyway: what about defining a complete graph on your points, in which each edge has a color associated to its length. Wouldn't the automorphism group of that be what you want?

That is a valid definition. But the standard one is the set of orthogonal matrices that preserve the polyhedron. And it would be nice for isometry_group to be a finite matrix group (and not permutations)!

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 9 years ago

Changed commit from fac3cff to 1a82754

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 9 years ago

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

21e70a7Trac 18213: review commit
1a82754Trac 18213: doctest fix
videlec commented 9 years ago
comment:42

Patchbot should be happy after that.

6bdad4c1-1e26-4f2f-a442-a01a2292c181 commented 9 years ago
comment:43

Some broken doctests in the patchbot's report. Also, can you be sure that the sqrt(6.) / factorial(5) are not subject to numerical noise? There is no #tol on them right now.

Nathann

6bdad4c1-1e26-4f2f-a442-a01a2292c181 commented 9 years ago
comment:44

Hmmmmmm.. I can't seem to find on google an implementation of an isometry group function anywhere O_o

a1031e5c-5e2c-4c90-8ba4-91be67e304df commented 9 years ago
comment:45

Hi Vincent and Nathann

Just a quick comment, as I'm not sure how useful this will be for general polyhedra: There is a method for lattice polytopes: LatticePolytope_PPL (in sage.geometry.polyhedron.ppl_lattice_polytope) has a method lattice_automorphism_group()

Cheers, Jan

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 9 years ago

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

120c1e9Trac 18213: more abs tol in doctests
d09d8a5Trac 18211: forgot a # optional in the doctest
a58da00Trac 18213: merge failed doctest from #18211
7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 9 years ago

Changed commit from 1a82754 to a58da00

videlec commented 9 years ago
comment:48

Replying to @nathanncohen:

Some broken doctests in the patchbot's report. Also, can you be sure that the sqrt(6.) / factorial(5) are not subject to numerical noise? There is no #tol on them right now.

I don't know... Patchbot did not complain about this.

6bdad4c1-1e26-4f2f-a442-a01a2292c181 commented 9 years ago
comment:50

Okayyyyyyy. Then positive_review!

Nathann

6bdad4c1-1e26-4f2f-a442-a01a2292c181 commented 9 years ago

Reviewer: Nathann Cohen

vbraun commented 9 years ago

Changed branch from u/vdelecroix/18213 to a58da00