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

sage.geometry.polyhedron: fix doctest error due to modularization #36089

Merged
merged 1 commit into from
Aug 27, 2023

Conversation

dcoudert
Copy link
Contributor

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

  • The title is concise, informative, and self-explanatory.
  • 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

@github-actions
Copy link

Documentation preview for this PR (built with commit fc72523; changes) is ready! 🎉

vbraun pushed a commit to vbraun/sage that referenced this pull request Aug 23, 2023
…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
@vbraun vbraun merged commit 159a6f9 into sagemath:develop Aug 27, 2023
17 of 18 checks passed
@mkoeppe mkoeppe added this to the sage-10.2 milestone Aug 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants