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

Commit

Permalink
merged in public/29904
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonathan Kliem committed Jun 19, 2020
2 parents 0bdbe49 + 5c7e562 commit 206dbb7
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/sage/geometry/polyhedron/library.py
Original file line number Diff line number Diff line change
Expand Up @@ -3127,6 +3127,12 @@ def hypercube(self, dim, intervals=None, backend=None):
sage: P = polytopes.hypercube(4, intervals, backend='field')
sage: TestSuite(P).run()
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 @@ -3152,8 +3158,7 @@ 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: set_random_seed()
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 @@ -3210,7 +3215,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 206dbb7

Please sign in to comment.