Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
Merge branch 'public/29904' of git://trac.sagemath.org/sage into publ…
Browse files Browse the repository at this point in the history
…ic/29962
  • Loading branch information
Jonathan Kliem committed Jun 24, 2020
2 parents 228f379 + e1bf211 commit 0e7a998
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/sage/geometry/polyhedron/library.py
Original file line number Diff line number Diff line change
Expand Up @@ -3101,6 +3101,12 @@ def hypercube(self, dim, intervals=None, backend=None):
sage: fc = polytopes.hypercube(4,backend='normaliz') # optional - pynormaliz
sage: TestSuite(fc).run() # optional - pynormaliz
Check that :trac:`29904` is fixed::
sage: intervals = [[-2,2]]
sage: P = polytopes.hypercube(1, intervals, 'field')
sage: TestSuite(P).run()
If the dimension ``dim`` is not equal to the length of intervals, an
error is raised::
Expand All @@ -3126,8 +3132,6 @@ def hypercube(self, dim, intervals=None, backend=None):
Check that we set up the hypercube correctly::
sage: ls = [randint(-100,100) for _ in range(4)]
sage: intervals = [[x, x+randint(1,50)] for x in ls]
sage: ls = [randint(-100,100) for _ in range(4)]
sage: intervals = [[x, x+randint(1,50)] for x in ls]
sage: P = polytopes.hypercube(4, intervals, backend='field')
Expand Down Expand Up @@ -3184,7 +3188,7 @@ def hypercube(self, dim, intervals=None, backend=None):
# An inequality -x_i + b_i >= 0 for i < dim
# resp. x_{dim-i} - a_i >= 0 for i >= dim
ieq_b = lambda i: intervals[i][1] if i < dim \
else intervals[i-dim][0]
else -intervals[i-dim][0]
else:
raise ValueError("the dimension of the hypercube must match the number of intervals")

Expand Down

0 comments on commit 0e7a998

Please sign in to comment.