Skip to content

Commit

Permalink
sagemathgh-36089: sage.geometry.polyhedron: fix doctest error due t…
Browse files Browse the repository at this point in the history
…o modularization

On MacOS with sagemath 10.1.rc0, I have the following doctest error in
`src/sage/geometry/polyhedron/base_ZZ.py`

```
sage -t --long --warn-long 18.5 --random-
seed=240228246560107174999702016603267109757
src/sage/geometry/polyhedron/base_ZZ.py
**********************************************************************
File "src/sage/geometry/polyhedron/base_ZZ.py", line 419, in
sage.geometry.polyhedron.base_ZZ.Polyhedron_ZZ.?
Failed example:
    hypercube(3).ehrhart_polynomial(engine='normaliz')
Exception raised:
    Traceback (most recent call last):
      File "/Users/dcoudert/sage/src/sage/doctest/forker.py", line 709,
in _run
        self.compile_and_execute(example, compiler, test.globs)
      File "/Users/dcoudert/sage/src/sage/doctest/forker.py", line 1144,
in compile_and_execute
        exec(compiled, globs)
      File "<doctest
sage.geometry.polyhedron.base_ZZ.Polyhedron_ZZ.?[9]>", line 1, in
<module>
        hypercube(Integer(3)).ehrhart_polynomial(engine='normaliz')
        ^^^^^^^^^^^^^^^^^^^^^
      File "<doctest
sage.geometry.polyhedron.base_ZZ.Polyhedron_ZZ.?[8]>", line 2, in
hypercube
        return Polyhedron(vertices=list(product([Integer(0),Integer(1)],
repeat=d)),backend='normaliz')
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    TypeError: 'sage.rings.integer.Integer' object is not iterable
**********************************************************************
File "src/sage/geometry/polyhedron/base_ZZ.py", line 421, in
sage.geometry.polyhedron.base_ZZ.Polyhedron_ZZ.?
Failed example:
    hypercube(4).ehrhart_polynomial(engine='normaliz')
Exception raised:
    Traceback (most recent call last):
      File "/Users/dcoudert/sage/src/sage/doctest/forker.py", line 709,
in _run
        self.compile_and_execute(example, compiler, test.globs)
      File "/Users/dcoudert/sage/src/sage/doctest/forker.py", line 1144,
in compile_and_execute
        exec(compiled, globs)
      File "<doctest
sage.geometry.polyhedron.base_ZZ.Polyhedron_ZZ.?[10]>", line 1, in
<module>
        hypercube(Integer(4)).ehrhart_polynomial(engine='normaliz')
        ^^^^^^^^^^^^^^^^^^^^^
      File "<doctest
sage.geometry.polyhedron.base_ZZ.Polyhedron_ZZ.?[8]>", line 2, in
hypercube
        return Polyhedron(vertices=list(product([Integer(0),Integer(1)],
repeat=d)),backend='normaliz')
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    TypeError: 'sage.rings.integer.Integer' object is not iterable
**********************************************************************
File "src/sage/geometry/polyhedron/base_ZZ.py", line 423, in
sage.geometry.polyhedron.base_ZZ.Polyhedron_ZZ.?
Failed example:
    hypercube(5).ehrhart_polynomial(engine='normaliz')
Exception raised:
    Traceback (most recent call last):
      File "/Users/dcoudert/sage/src/sage/doctest/forker.py", line 709,
in _run
        self.compile_and_execute(example, compiler, test.globs)
      File "/Users/dcoudert/sage/src/sage/doctest/forker.py", line 1144,
in compile_and_execute
        exec(compiled, globs)
      File "<doctest
sage.geometry.polyhedron.base_ZZ.Polyhedron_ZZ.?[11]>", line 1, in
<module>
        hypercube(Integer(5)).ehrhart_polynomial(engine='normaliz')
        ^^^^^^^^^^^^^^^^^^^^^
      File "<doctest
sage.geometry.polyhedron.base_ZZ.Polyhedron_ZZ.?[8]>", line 2, in
hypercube
        return Polyhedron(vertices=list(product([Integer(0),Integer(1)],
repeat=d)),backend='normaliz')
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    TypeError: 'sage.rings.integer.Integer' object is not iterable
**********************************************************************
File "src/sage/geometry/polyhedron/base_ZZ.py", line 425, in
sage.geometry.polyhedron.base_ZZ.Polyhedron_ZZ.?
Failed example:
    hypercube(6).ehrhart_polynomial(engine='normaliz')
Exception raised:
    Traceback (most recent call last):
      File "/Users/dcoudert/sage/src/sage/doctest/forker.py", line 709,
in _run
        self.compile_and_execute(example, compiler, test.globs)
      File "/Users/dcoudert/sage/src/sage/doctest/forker.py", line 1144,
in compile_and_execute
        exec(compiled, globs)
      File "<doctest
sage.geometry.polyhedron.base_ZZ.Polyhedron_ZZ.?[12]>", line 1, in
<module>
        hypercube(Integer(6)).ehrhart_polynomial(engine='normaliz')
        ^^^^^^^^^^^^^^^^^^^^^
      File "<doctest
sage.geometry.polyhedron.base_ZZ.Polyhedron_ZZ.?[8]>", line 2, in
hypercube
        return Polyhedron(vertices=list(product([Integer(0),Integer(1)],
repeat=d)),backend='normaliz')
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    TypeError: 'sage.rings.integer.Integer' object is not iterable
```

This is caused by the `from itertools import product` in a block
starting with `# optional - latte_int`. Apparently I don't have
`latte_int` installed, and so this import is not done when starting the
block with `pynormaliz` (I have it). So the fix is trivial.

### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. -->
<!-- If your change requires a documentation PR, please link it
appropriately -->
<!-- If you're unsure about any of these, don't hesitate to ask. We're
here to help! -->
<!-- Feel free to remove irrelevant items. -->

- [x] The title is concise, informative, and self-explanatory.
- [x] The description explains in detail what this PR is about.
- [ ] I have linked a relevant issue or discussion.
- [ ] I have created tests covering the changes.
- [ ] I have updated the documentation accordingly.

### ⌛ Dependencies

<!-- List all open PRs that this PR logically depends on
- sagemath#12345: short description why this is a dependency
- sagemath#34567: ...
-->

<!-- If you're unsure about any of these, don't hesitate to ask. We're
here to help! -->

URL: sagemath#36089
Reported by: David Coudert
Reviewer(s): Matthias Köppe
  • Loading branch information
Release Manager committed Aug 23, 2023
2 parents 1bdb52e + fc72523 commit b72f344
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
6 changes: 3 additions & 3 deletions build/pkgs/configure/checksums.ini
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
tarball=configure-VERSION.tar.gz
sha1=15c6dc9764f4e9dfc526e7131483989b8ea72430
md5=c46a0fd95ab6860f6d7185ca467b1df2
cksum=427186534
sha1=3fe1229c8dc598725a50244edf2fdfe8c9e1de42
md5=bc04092e8aaa5f30d06a55c20dfec9c7
cksum=2759448981
2 changes: 1 addition & 1 deletion build/pkgs/configure/package-version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
aa220c4a1e34607d75d86b5abe022bd0c0358644
8779079c99d2cfa88c4de1dcb7dbf12d66ce1cba
1 change: 1 addition & 0 deletions src/sage/geometry/polyhedron/base_ZZ.py
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,7 @@ def ehrhart_polynomial(self, engine=None, variable='t', verbose=False, dual=None
t^6 + 6*t^5 + 15*t^4 + 20*t^3 + 15*t^2 + 6*t + 1
sage: # optional - pynormaliz
sage: from itertools import product
sage: def hypercube(d):
....: return Polyhedron(vertices=list(product([0,1],repeat=d)),backend='normaliz')
sage: hypercube(3).ehrhart_polynomial(engine='normaliz')
Expand Down

0 comments on commit b72f344

Please sign in to comment.