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

IndexError in integral_points_count of Polyhedron #21491

Closed
seblabbe opened this issue Sep 14, 2016 · 21 comments
Closed

IndexError in integral_points_count of Polyhedron #21491

seblabbe opened this issue Sep 14, 2016 · 21 comments

Comments

@seblabbe
Copy link
Contributor

With latte_int installed:

$ sage -experimental
...
latte_int...............................1.7.3 (1.7.3)
...

I get:

sage: eqns = [[-10, 0, 1], [-10, 1, 0]]
sage: P = Polyhedron(ieqs=[], eqns=eqns)
sage: P.integral_points_count()
...
sage/geometry/polyhedron/base.pyc in integral_points_count(self, verbose)
   4259             raise RuntimeError("LattE integrale failed (exit code {}) to execute {}".format(ret_code, ' '.join(args)) + err.strip())
   4260
-> 4261         return Integer(ans.splitlines()[-1])
   4262
   4263     def integral_points(self, threshold=100000):

IndexError: list index out of range

Same error with:

sage: P = Polyhedron(ieqs=[], eqns=[[-11,0,2],[-10,1,0]])
sage: P.vertices()
(A vertex at (10, 11/2),)

The culprit might be the empty string:

sage: "".splitlines()[-1]
---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
<ipython-input-1-7faf349df14a> in <module>()
----> 1 "".splitlines()[-Integer(1)]

IndexError: list index out of range

CC: @mkoeppe

Component: geometry

Keywords: days79

Author: Sébastien Labbé

Branch/Commit: ce82303

Reviewer: Moritz Firsching, Travis Scrimshaw

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

@seblabbe seblabbe added this to the sage-7.4 milestone Sep 14, 2016
@seblabbe
Copy link
Contributor Author

comment:2

Just to say that in both cases, latte_int gets the answer right.

1 in this case:

sage: P = Polyhedron(ieqs=[], eqns=[[-10, 0, 1], [-10, 1, 0]])
sage: P.integral_points_count(verbose=True)
This is LattE integrale 1.7.3
Available from http://www.math.ucdavis.edu/~latte/
...
Ax <= b, given as (b|-A):
=========================
[]

Ax = b, given as (b|-A):
========================
[-10 0 1]
[-10 1 0]

The number of lattice points is 1.
---------------------------------------------------------------------------
Traceback (most recent call last)
...
IndexError: list index out of range

0 in this case:

sage: P = Polyhedron(ieqs=[], eqns=[[-11,0,2],[-10,1,0]])
sage: P.integral_points_count(verbose=True)
This is LattE integrale 1.7.3
Available from http://www.math.ucdavis.edu/~latte/
...
Ax <= b, given as (b|-A):
=========================
[]

Ax = b, given as (b|-A):
========================
[-11 0 2]
[-10 1 0]

The number of lattice points is 0.
---------------------------------------------------------------------------
Traceback (most recent call last)
...
IndexError: list index out of range

@seblabbe
Copy link
Contributor Author

seblabbe commented Nov 2, 2016

Commit: 27948e8

@seblabbe
Copy link
Contributor Author

seblabbe commented Nov 2, 2016

Author: Sébastien Labbé

@seblabbe
Copy link
Contributor Author

seblabbe commented Nov 2, 2016

New commits:

27948e821491: using file numOfLatticePoints for integral_points_count method

@seblabbe
Copy link
Contributor Author

seblabbe commented Nov 2, 2016

Branch: u/slabbe/21491

@mo271
Copy link
Contributor

mo271 commented Nov 23, 2016

comment:4

This seems to work!

@seblabbe
Copy link
Contributor Author

comment:6

Thanks for the review!

@seblabbe
Copy link
Contributor Author

Changed keywords from none to days79

@seblabbe
Copy link
Contributor Author

Reviewer: Moritz Minzlaff

@tscrim
Copy link
Collaborator

tscrim commented Nov 23, 2016

comment:8

Since opening a file takes ~10x longer than a try/except block, I suggest the following:

        try:
            return Integer(ans.splitlines()[-1])
        except IndexError:
            with open(SAGE_TMP+'/numOfLatticePoints', 'r') as f:
                return Integer(f.read())

@mo271
Copy link
Contributor

mo271 commented Nov 23, 2016

Changed reviewer from Moritz Minzlaff to Moritz Firsching

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Nov 23, 2016

Changed commit from 27948e8 to 347aa90

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Nov 23, 2016

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

347aa9021491: catching the IndexError instead

@tscrim
Copy link
Collaborator

tscrim commented Nov 23, 2016

comment:12

Thanks.

@tscrim
Copy link
Collaborator

tscrim commented Nov 23, 2016

Changed reviewer from Moritz Firsching to Moritz Firsching, Travis Scrimshaw

@vbraun
Copy link
Member

vbraun commented Nov 25, 2016

comment:13

Documentation doesn't build, see patchbot.

@tscrim
Copy link
Collaborator

tscrim commented Nov 26, 2016

comment:14

Trivial fix TESTS:: -> TESTS:, so I'm allowing myself to set this back to positive review.


New commits:

b090df5Merge branch 'u/slabbe/21491' of trac.sagemath.org:sage into u/tsrcim/21491
ce82303Fixing doc for #21491.

@tscrim
Copy link
Collaborator

tscrim commented Nov 26, 2016

Changed commit from 347aa90 to ce82303

@tscrim
Copy link
Collaborator

tscrim commented Nov 26, 2016

Changed branch from u/slabbe/21491 to u/tscrim/21491

@seblabbe
Copy link
Contributor Author

comment:15

Thank you for fixing this Travis.

Sébastien

@vbraun
Copy link
Member

vbraun commented Nov 28, 2016

Changed branch from u/tscrim/21491 to ce82303

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

4 participants