Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 42 additions & 32 deletions src/sage/geometry/cone.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,20 +201,28 @@
# (at your option) any later version.
# https://www.gnu.org/licenses/
# ****************************************************************************
from __future__ import annotations

from collections.abc import Hashable, Iterable, Container
from collections.abc import Container, Hashable, Iterable
from copy import copy
from typing import TYPE_CHECKING
from warnings import warn

from sage.misc.lazy_import import lazy_import

lazy_import('sage.combinat.posets.posets', 'FinitePoset')
from sage.arith.misc import GCD as gcd
from sage.arith.functions import lcm
from sage.arith.misc import GCD as gcd
from sage.geometry.point_collection import PointCollection
from sage.geometry.polyhedron.constructor import Polyhedron

lazy_import('sage.geometry.hasse_diagram', 'lattice_from_incidences')
from sage.geometry.toric_lattice import (ToricLattice, ToricLattice_generic,
ToricLattice_quotient)
from sage.geometry.toric_lattice import (
ToricLattice,
ToricLattice_generic,
ToricLattice_quotient,
)

lazy_import('sage.geometry.toric_plotter', ['ToricPlotter', 'label_list'])
from sage.geometry.relative_interior import RelativeInterior
from sage.matrix.constructor import matrix
Expand All @@ -223,24 +231,28 @@
from sage.misc.cachefunc import cached_method
from sage.misc.flatten import flatten
from sage.misc.latex import latex
from sage.modules.free_module import span, VectorSpace
from sage.modules.free_module import VectorSpace, span
from sage.modules.free_module_element import vector
from sage.rings.integer_ring import ZZ
from sage.rings.rational_field import QQ
from sage.structure.sage_object import SageObject
from sage.structure.element import parent
from sage.structure.richcmp import richcmp_method, richcmp
from sage.structure.richcmp import richcmp, richcmp_method
from sage.structure.sage_object import SageObject

lazy_import('sage.geometry.integral_points', 'parallelotope_points')
from sage.geometry.convex_set import ConvexSet_closed
import sage.geometry.abc

from sage.features import PythonModule
from sage.geometry.convex_set import ConvexSet_closed

lazy_import('ppl', ['C_Polyhedron', 'Generator_System', 'Constraint_System',
'Linear_Expression', 'Poly_Con_Relation'],
feature=PythonModule("ppl", spkg='pplpy', type='standard'))
lazy_import('ppl', ['ray', 'point'], as_=['PPL_ray', 'PPL_point'],
feature=PythonModule("ppl", spkg='pplpy', type='standard'))

if TYPE_CHECKING:
from sage.misc.sage_input import CoercionMode, SageInputBuilder, SageInputExpression


def is_Cone(x):
r"""
Expand Down Expand Up @@ -1510,7 +1522,7 @@
if PPL is not None:
self._PPL_C_Polyhedron = PPL

def _sage_input_(self, sib, coerced):
def _sage_input_(self, sib: SageInputBuilder, coerced: CoercionMode) -> SageInputExpression:
"""
Return Sage command to reconstruct ``self``.

Expand Down Expand Up @@ -2088,31 +2100,31 @@

First, we create a fan from two cones in the plane::

sage: fan = Fan(cones=[(0,1), (1,2)],

Check failure on line 2103 in src/sage/geometry/cone.py

View workflow job for this annotation

GitHub Actions / test-long (src/sage/[g-o]*)

Failed example:

Failed example:: Exception raised: Traceback (most recent call last): File "/sage/src/sage/doctest/forker.py", line 734, in _run self.compile_and_execute(example, compiler, test.globs) File "/sage/src/sage/doctest/forker.py", line 1158, in compile_and_execute exec(compiled, globs) File "<doctest sage.geometry.cone.ConvexRationalPolyhedralCone.adjacent[5]>", line 1, in <module> fan = Fan(cones=[(Integer(0),Integer(1)), (Integer(1),Integer(2))], ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "sage/misc/lazy_import.pyx", line 413, in sage.misc.lazy_import.LazyImport.__call__ File "sage/misc/lazy_import.pyx", line 231, in sage.misc.lazy_import.LazyImport.get_object File "sage/misc/lazy_import.pyx", line 266, in sage.misc.lazy_import.LazyImport._get_object File "/sage/src/sage/geometry/fan.py", line 1148, in <module> @richcmp_method ^^^^^^^^^^^^^^ NameError: name 'richcmp_method' is not defined. Did you mean: 'cached_method'?
....: rays=[(1,0), (0,1), (-1,0)])
sage: cone = fan.generating_cone(0)

Check failure on line 2105 in src/sage/geometry/cone.py

View workflow job for this annotation

GitHub Actions / test-long (src/sage/[g-o]*)

Failed example:

Failed example:: Exception raised: Traceback (most recent call last): File "/sage/src/sage/doctest/forker.py", line 734, in _run self.compile_and_execute(example, compiler, test.globs) File "/sage/src/sage/doctest/forker.py", line 1158, in compile_and_execute exec(compiled, globs) File "<doctest sage.geometry.cone.ConvexRationalPolyhedralCone.adjacent[6]>", line 1, in <module> cone = fan.generating_cone(Integer(0)) ^^^ NameError: name 'fan' is not defined
sage: len(cone.adjacent()) # needs sage.graphs

Check failure on line 2106 in src/sage/geometry/cone.py

View workflow job for this annotation

GitHub Actions / test-long (src/sage/[g-o]*)

Failed example:

Failed example:: Exception raised: Traceback (most recent call last): File "/sage/src/sage/doctest/forker.py", line 734, in _run self.compile_and_execute(example, compiler, test.globs) File "/sage/src/sage/doctest/forker.py", line 1158, in compile_and_execute exec(compiled, globs) File "<doctest sage.geometry.cone.ConvexRationalPolyhedralCone.adjacent[7]>", line 1, in <module> len(cone.adjacent()) # needs sage.graphs ^^^^ NameError: name 'cone' is not defined
1

The second generating cone is adjacent to this one. Now we create the
same fan, but embedded into the 3-dimensional space::

sage: fan = Fan(cones=[(0,1), (1,2)],

Check failure on line 2112 in src/sage/geometry/cone.py

View workflow job for this annotation

GitHub Actions / test-long (src/sage/[g-o]*)

Failed example:

Failed example:: Exception raised: Traceback (most recent call last): File "/sage/src/sage/doctest/forker.py", line 734, in _run self.compile_and_execute(example, compiler, test.globs) File "/sage/src/sage/doctest/forker.py", line 1158, in compile_and_execute exec(compiled, globs) File "<doctest sage.geometry.cone.ConvexRationalPolyhedralCone.adjacent[8]>", line 1, in <module> fan = Fan(cones=[(Integer(0),Integer(1)), (Integer(1),Integer(2))], ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "sage/misc/lazy_import.pyx", line 413, in sage.misc.lazy_import.LazyImport.__call__ File "sage/misc/lazy_import.pyx", line 231, in sage.misc.lazy_import.LazyImport.get_object File "sage/misc/lazy_import.pyx", line 266, in sage.misc.lazy_import.LazyImport._get_object File "/sage/src/sage/geometry/fan.py", line 1148, in <module> @richcmp_method ^^^^^^^^^^^^^^ NameError: name 'richcmp_method' is not defined. Did you mean: 'cached_method'?
....: rays=[(1,0,0), (0,1,0), (-1,0,0)])
sage: cone = fan.generating_cone(0)

Check failure on line 2114 in src/sage/geometry/cone.py

View workflow job for this annotation

GitHub Actions / test-long (src/sage/[g-o]*)

Failed example:

Failed example:: Exception raised: Traceback (most recent call last): File "/sage/src/sage/doctest/forker.py", line 734, in _run self.compile_and_execute(example, compiler, test.globs) File "/sage/src/sage/doctest/forker.py", line 1158, in compile_and_execute exec(compiled, globs) File "<doctest sage.geometry.cone.ConvexRationalPolyhedralCone.adjacent[9]>", line 1, in <module> cone = fan.generating_cone(Integer(0)) ^^^ NameError: name 'fan' is not defined
sage: len(cone.adjacent()) # needs sage.graphs

Check failure on line 2115 in src/sage/geometry/cone.py

View workflow job for this annotation

GitHub Actions / test-long (src/sage/[g-o]*)

Failed example:

Failed example:: Exception raised: Traceback (most recent call last): File "/sage/src/sage/doctest/forker.py", line 734, in _run self.compile_and_execute(example, compiler, test.globs) File "/sage/src/sage/doctest/forker.py", line 1158, in compile_and_execute exec(compiled, globs) File "<doctest sage.geometry.cone.ConvexRationalPolyhedralCone.adjacent[10]>", line 1, in <module> len(cone.adjacent()) # needs sage.graphs ^^^^ NameError: name 'cone' is not defined
1

The result is as before, since we still have::

sage: fan.dim()

Check failure on line 2120 in src/sage/geometry/cone.py

View workflow job for this annotation

GitHub Actions / test-long (src/sage/[g-o]*)

Failed example:

Failed example:: Exception raised: Traceback (most recent call last): File "/sage/src/sage/doctest/forker.py", line 734, in _run self.compile_and_execute(example, compiler, test.globs) File "/sage/src/sage/doctest/forker.py", line 1158, in compile_and_execute exec(compiled, globs) File "<doctest sage.geometry.cone.ConvexRationalPolyhedralCone.adjacent[11]>", line 1, in <module> fan.dim() ^^^ NameError: name 'fan' is not defined
2

Now we add another cone to make the fan 3-dimensional::

sage: fan = Fan(cones=[(0,1), (1,2), (3,)],

Check failure on line 2125 in src/sage/geometry/cone.py

View workflow job for this annotation

GitHub Actions / test-long (src/sage/[g-o]*)

Failed example:

Failed example:: Exception raised: Traceback (most recent call last): File "/sage/src/sage/doctest/forker.py", line 734, in _run self.compile_and_execute(example, compiler, test.globs) File "/sage/src/sage/doctest/forker.py", line 1158, in compile_and_execute exec(compiled, globs) File "<doctest sage.geometry.cone.ConvexRationalPolyhedralCone.adjacent[12]>", line 1, in <module> fan = Fan(cones=[(Integer(0),Integer(1)), (Integer(1),Integer(2)), (Integer(3),)], ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "sage/misc/lazy_import.pyx", line 413, in sage.misc.lazy_import.LazyImport.__call__ File "sage/misc/lazy_import.pyx", line 231, in sage.misc.lazy_import.LazyImport.get_object File "sage/misc/lazy_import.pyx", line 266, in sage.misc.lazy_import.LazyImport._get_object File "/sage/src/sage/geometry/fan.py", line 1148, in <module> @richcmp_method ^^^^^^^^^^^^^^ NameError: name 'richcmp_method' is not defined. Did you mean: 'cached_method'?
....: rays=[(1,0,0), (0,1,0), (-1,0,0), (0,0,1)])
sage: cone = fan.generating_cone(0)

Check failure on line 2127 in src/sage/geometry/cone.py

View workflow job for this annotation

GitHub Actions / test-long (src/sage/[g-o]*)

Failed example:

Failed example:: Exception raised: Traceback (most recent call last): File "/sage/src/sage/doctest/forker.py", line 734, in _run self.compile_and_execute(example, compiler, test.globs) File "/sage/src/sage/doctest/forker.py", line 1158, in compile_and_execute exec(compiled, globs) File "<doctest sage.geometry.cone.ConvexRationalPolyhedralCone.adjacent[13]>", line 1, in <module> cone = fan.generating_cone(Integer(0)) ^^^ NameError: name 'fan' is not defined
sage: len(cone.adjacent()) # needs sage.graphs
0

Expand Down Expand Up @@ -4328,8 +4340,9 @@
# recursively
N = self.lattice()
if not self.is_simplicial():
from sage.geometry.triangulation.point_configuration \
import PointConfiguration
from sage.geometry.triangulation.point_configuration import (
PointConfiguration,
)
origin = self.n_rays() # last one in pc
pc = PointConfiguration(tuple(self.rays()) + (N(0),), star=origin)
triangulation = pc.triangulate()
Expand Down Expand Up @@ -6772,12 +6785,11 @@
msg = 'max_rays must be at least min_ambient_dim for '
msg += 'a solid cone.'
raise ValueError(msg)
else:
# Repeat the checks above when a lattice is given.
if max_rays is not None and max_rays < lattice.dimension():
msg = "max_rays must be at least {0} for a solid cone "
msg += "in this lattice."
raise ValueError(msg.format(lattice.dimension()))
# Repeat the checks above when a lattice is given.
elif max_rays is not None and max_rays < lattice.dimension():
msg = "max_rays must be at least {0} for a solid cone "
msg += "in this lattice."
raise ValueError(msg.format(lattice.dimension()))

# Sanity checks for non-solid cones.
if solid is not None and not solid:
Expand Down Expand Up @@ -6852,9 +6864,8 @@
if (max_ambient_dim is not None and
K.lattice_dim() > max_ambient_dim):
return False
else:
if K.lattice() is not lattice:
return False
elif K.lattice() is not lattice:
return False
return all([K.n_rays() >= min_rays,
max_rays is None or K.n_rays() <= max_rays,
solid is None or K.is_solid() == solid,
Expand Down Expand Up @@ -6945,17 +6956,16 @@
rays[i][0] = pm * (ray[0].abs() + 1)

K = Cone(rays, lattice=L)
else:
# The user requested that the cone be NOT strictly
# convex. So it should contain some line...
if K.is_strictly_convex():
# ...but it doesn't. If K has at least two rays,
# we can just make the second one a multiple of
# the first -- then K will contain a line. If K
# has fewer than two rays, we punt.
if len(rays) >= 2:
rays[1] = -rays[0]
K = Cone(rays, lattice=L)
# The user requested that the cone be NOT strictly
# convex. So it should contain some line...
elif K.is_strictly_convex():
# ...but it doesn't. If K has at least two rays,
# we can just make the second one a multiple of
# the first -- then K will contain a line. If K
# has fewer than two rays, we punt.
if len(rays) >= 2:
rays[1] = -rays[0]
K = Cone(rays, lattice=L)

if is_valid(K):
# Loop if we don't have a valid cone.
Expand Down
17 changes: 11 additions & 6 deletions src/sage/geometry/fan.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@

Use :func:`Fan` to construct fans "explicitly"::

sage: fan = Fan(cones=[(0,1), (1,2)],

Check failure on line 31 in src/sage/geometry/fan.py

View workflow job for this annotation

GitHub Actions / Conda (ubuntu, Python 3.12, new)

Failed example:

Failed example:: Exception raised: Traceback (most recent call last): File "/usr/share/miniconda/envs/sage-dev/lib/python3.12/site-packages/sage/doctest/forker.py", line 734, in _run self.compile_and_execute(example, compiler, test.globs) File "/usr/share/miniconda/envs/sage-dev/lib/python3.12/site-packages/sage/doctest/forker.py", line 1158, in compile_and_execute exec(compiled, globs) File "<doctest sage.geometry.fan[0]>", line 1, in <module> fan = Fan(cones=[(Integer(0),Integer(1)), (Integer(1),Integer(2))], ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "sage/misc/lazy_import.pyx", line 413, in sage.misc.lazy_import.LazyImport.__call__ return self.get_object()(*args, **kwds) File "sage/misc/lazy_import.pyx", line 231, in sage.misc.lazy_import.LazyImport.get_object return self._get_object() File "sage/misc/lazy_import.pyx", line 266, in sage.misc.lazy_import.LazyImport._get_object self._object = getattr(__import__(self._module, {}, {}, [self._name]), self._name) File "/usr/share/miniconda/envs/sage-dev/lib/python3.12/site-packages/sage/geometry/fan.py", line 1148, in <module> @richcmp_method ^^^^^^^^^^^^^^ NameError: name 'richcmp_method' is not defined. Did you mean: 'cached_method'?
....: rays=[(1,0), (0,1), (-1,0)])
sage: fan

Check failure on line 33 in src/sage/geometry/fan.py

View workflow job for this annotation

GitHub Actions / Conda (ubuntu, Python 3.12, new)

Failed example:

Failed example:: Exception raised: Traceback (most recent call last): File "/usr/share/miniconda/envs/sage-dev/lib/python3.12/site-packages/sage/doctest/forker.py", line 734, in _run self.compile_and_execute(example, compiler, test.globs) File "/usr/share/miniconda/envs/sage-dev/lib/python3.12/site-packages/sage/doctest/forker.py", line 1158, in compile_and_execute exec(compiled, globs) File "<doctest sage.geometry.fan[1]>", line 1, in <module> fan NameError: name 'fan' is not defined
Rational polyhedral fan in 2-d lattice N

In addition to giving such lists of cones and rays you can also create cones
Expand All @@ -40,8 +40,8 @@
In 2 dimensions there is a unique maximal fan determined by rays, and
you can use :func:`Fan2d` to construct it::

sage: fan2d = Fan2d(rays=[(1,0), (0,1), (-1,0)])

Check failure on line 43 in src/sage/geometry/fan.py

View workflow job for this annotation

GitHub Actions / Conda (ubuntu, Python 3.12, new)

Failed example:

Failed example:: Exception raised: Traceback (most recent call last): File "/usr/share/miniconda/envs/sage-dev/lib/python3.12/site-packages/sage/doctest/forker.py", line 734, in _run self.compile_and_execute(example, compiler, test.globs) File "/usr/share/miniconda/envs/sage-dev/lib/python3.12/site-packages/sage/doctest/forker.py", line 1158, in compile_and_execute exec(compiled, globs) File "<doctest sage.geometry.fan[2]>", line 1, in <module> fan2d = Fan2d(rays=[(Integer(1),Integer(0)), (Integer(0),Integer(1)), (-Integer(1),Integer(0))]) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "sage/misc/lazy_import.pyx", line 413, in sage.misc.lazy_import.LazyImport.__call__ return self.get_object()(*args, **kwds) File "sage/misc/lazy_import.pyx", line 231, in sage.misc.lazy_import.LazyImport.get_object return self._get_object() File "sage/misc/lazy_import.pyx", line 266, in sage.misc.lazy_import.LazyImport._get_object self._object = getattr(__import__(self._module, {}, {}, [self._name]), self._name) File "/usr/share/miniconda/envs/sage-dev/lib/python3.12/site-packages/sage/geometry/fan.py", line 1148, in <module> @richcmp_method ^^^^^^^^^^^^^^ NameError: name 'richcmp_method' is not defined. Did you mean: 'cached_method'?
sage: fan2d.is_equivalent(fan)

Check failure on line 44 in src/sage/geometry/fan.py

View workflow job for this annotation

GitHub Actions / Conda (ubuntu, Python 3.12, new)

Failed example:

Failed example:: Exception raised: Traceback (most recent call last): File "/usr/share/miniconda/envs/sage-dev/lib/python3.12/site-packages/sage/doctest/forker.py", line 734, in _run self.compile_and_execute(example, compiler, test.globs) File "/usr/share/miniconda/envs/sage-dev/lib/python3.12/site-packages/sage/doctest/forker.py", line 1158, in compile_and_execute exec(compiled, globs) File "<doctest sage.geometry.fan[3]>", line 1, in <module> fan2d.is_equivalent(fan) ^^^^^ NameError: name 'fan2d' is not defined
True

But keep in mind that in higher dimensions the cone data is essential
Expand All @@ -51,12 +51,12 @@
<sage.geometry.lattice_polytope.LatticePolytopeClass>`:
:func:`FaceFan` and :func:`NormalFan`::

sage: fan1 = FaceFan(lattice_polytope.cross_polytope(3))

Check failure on line 54 in src/sage/geometry/fan.py

View workflow job for this annotation

GitHub Actions / Conda (ubuntu, Python 3.12, new)

Failed example:

Failed example:: Exception raised: Traceback (most recent call last): File "/usr/share/miniconda/envs/sage-dev/lib/python3.12/site-packages/sage/doctest/forker.py", line 734, in _run self.compile_and_execute(example, compiler, test.globs) File "/usr/share/miniconda/envs/sage-dev/lib/python3.12/site-packages/sage/doctest/forker.py", line 1158, in compile_and_execute exec(compiled, globs) File "<doctest sage.geometry.fan[4]>", line 1, in <module> fan1 = FaceFan(lattice_polytope.cross_polytope(Integer(3))) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "sage/misc/lazy_import.pyx", line 413, in sage.misc.lazy_import.LazyImport.__call__ return self.get_object()(*args, **kwds) File "sage/misc/lazy_import.pyx", line 231, in sage.misc.lazy_import.LazyImport.get_object return self._get_object() File "sage/misc/lazy_import.pyx", line 266, in sage.misc.lazy_import.LazyImport._get_object self._object = getattr(__import__(self._module, {}, {}, [self._name]), self._name) File "/usr/share/miniconda/envs/sage-dev/lib/python3.12/site-packages/sage/geometry/fan.py", line 1148, in <module> @richcmp_method ^^^^^^^^^^^^^^ NameError: name 'richcmp_method' is not defined. Did you mean: 'cached_method'?
sage: fan2 = NormalFan(lattice_polytope.cross_polytope(3))

Check failure on line 55 in src/sage/geometry/fan.py

View workflow job for this annotation

GitHub Actions / Conda (ubuntu, Python 3.12, new)

Failed example:

Failed example:: Exception raised: Traceback (most recent call last): File "/usr/share/miniconda/envs/sage-dev/lib/python3.12/site-packages/sage/doctest/forker.py", line 734, in _run self.compile_and_execute(example, compiler, test.globs) File "/usr/share/miniconda/envs/sage-dev/lib/python3.12/site-packages/sage/doctest/forker.py", line 1158, in compile_and_execute exec(compiled, globs) File "<doctest sage.geometry.fan[5]>", line 1, in <module> fan2 = NormalFan(lattice_polytope.cross_polytope(Integer(3))) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "sage/misc/lazy_import.pyx", line 413, in sage.misc.lazy_import.LazyImport.__call__ return self.get_object()(*args, **kwds) File "sage/misc/lazy_import.pyx", line 231, in sage.misc.lazy_import.LazyImport.get_object return self._get_object() File "sage/misc/lazy_import.pyx", line 266, in sage.misc.lazy_import.LazyImport._get_object self._object = getattr(__import__(self._module, {}, {}, [self._name]), self._name) File "/usr/share/miniconda/envs/sage-dev/lib/python3.12/site-packages/sage/geometry/fan.py", line 1148, in <module> @richcmp_method ^^^^^^^^^^^^^^ NameError: name 'richcmp_method' is not defined. Did you mean: 'cached_method'?

Given such "automatic" fans, you may wonder what are their rays and cones::

sage: fan1.rays()

Check failure on line 59 in src/sage/geometry/fan.py

View workflow job for this annotation

GitHub Actions / Conda (ubuntu, Python 3.12, new)

Failed example:

Failed example:: Exception raised: Traceback (most recent call last): File "/usr/share/miniconda/envs/sage-dev/lib/python3.12/site-packages/sage/doctest/forker.py", line 734, in _run self.compile_and_execute(example, compiler, test.globs) File "/usr/share/miniconda/envs/sage-dev/lib/python3.12/site-packages/sage/doctest/forker.py", line 1158, in compile_and_execute exec(compiled, globs) File "<doctest sage.geometry.fan[6]>", line 1, in <module> fan1.rays() ^^^^ NameError: name 'fan1' is not defined
M( 1, 0, 0),
M( 0, 1, 0),
M( 0, 0, 1),
Expand All @@ -64,7 +64,7 @@
M( 0, -1, 0),
M( 0, 0, -1)
in 3-d lattice M
sage: fan1.generating_cones()

Check failure on line 67 in src/sage/geometry/fan.py

View workflow job for this annotation

GitHub Actions / Conda (ubuntu, Python 3.12, new)

Failed example:

Failed example:: Exception raised: Traceback (most recent call last): File "/usr/share/miniconda/envs/sage-dev/lib/python3.12/site-packages/sage/doctest/forker.py", line 734, in _run self.compile_and_execute(example, compiler, test.globs) File "/usr/share/miniconda/envs/sage-dev/lib/python3.12/site-packages/sage/doctest/forker.py", line 1158, in compile_and_execute exec(compiled, globs) File "<doctest sage.geometry.fan[7]>", line 1, in <module> fan1.generating_cones() ^^^^ NameError: name 'fan1' is not defined
(3-d cone of Rational polyhedral fan in 3-d lattice M,
3-d cone of Rational polyhedral fan in 3-d lattice M,
3-d cone of Rational polyhedral fan in 3-d lattice M,
Expand All @@ -76,7 +76,7 @@

The last output is not very illuminating. Let's try to improve it::

sage: for cone in fan1: print(cone.rays())

Check failure on line 79 in src/sage/geometry/fan.py

View workflow job for this annotation

GitHub Actions / Conda (ubuntu, Python 3.12, new)

Failed example:

Failed example:: Exception raised: Traceback (most recent call last): File "/usr/share/miniconda/envs/sage-dev/lib/python3.12/site-packages/sage/doctest/forker.py", line 734, in _run self.compile_and_execute(example, compiler, test.globs) File "/usr/share/miniconda/envs/sage-dev/lib/python3.12/site-packages/sage/doctest/forker.py", line 1158, in compile_and_execute exec(compiled, globs) File "<doctest sage.geometry.fan[8]>", line 1, in <module> for cone in fan1: print(cone.rays()) ^^^^ NameError: name 'fan1' is not defined
M( 0, 1, 0),
M( 0, 0, 1),
M(-1, 0, 0)
Expand Down Expand Up @@ -112,7 +112,7 @@

You can also do ::

sage: for cone in fan1: print(cone.ambient_ray_indices())

Check failure on line 115 in src/sage/geometry/fan.py

View workflow job for this annotation

GitHub Actions / Conda (ubuntu, Python 3.12, new)

Failed example:

Failed example:: Exception raised: Traceback (most recent call last): File "/usr/share/miniconda/envs/sage-dev/lib/python3.12/site-packages/sage/doctest/forker.py", line 734, in _run self.compile_and_execute(example, compiler, test.globs) File "/usr/share/miniconda/envs/sage-dev/lib/python3.12/site-packages/sage/doctest/forker.py", line 1158, in compile_and_execute exec(compiled, globs) File "<doctest sage.geometry.fan[9]>", line 1, in <module> for cone in fan1: print(cone.ambient_ray_indices()) ^^^^ NameError: name 'fan1' is not defined
(1, 2, 3)
(2, 3, 4)
(3, 4, 5)
Expand Down Expand Up @@ -233,14 +233,14 @@
# (at your option) any later version.
# https://www.gnu.org/licenses/
# ****************************************************************************
from __future__ import annotations

from collections.abc import Callable, Container
from copy import copy
from typing import TYPE_CHECKING
from warnings import warn

import sage.geometry.abc

from sage.structure.richcmp import richcmp_method, richcmp
from sage.misc.lazy_import import lazy_import
lazy_import('sage.combinat.combination', 'Combinations')
lazy_import('sage.combinat.posets.posets', 'FinitePoset')
Expand All @@ -262,6 +262,9 @@
from sage.rings.integer_ring import ZZ
from sage.rings.rational_field import QQ

if TYPE_CHECKING:
from sage.misc.sage_input import CoercionMode, SageInputBuilder, SageInputExpression


def is_Fan(x) -> bool:
r"""
Expand Down Expand Up @@ -1217,7 +1220,7 @@
if virtual_rays is not None:
self._virtual_rays = PointCollection(virtual_rays, self.lattice())

def _sage_input_(self, sib, coerced):
def _sage_input_(self, sib: SageInputBuilder, coerced: CoercionMode) -> SageInputExpression:
"""
Return Sage command to reconstruct ``self``.

Expand Down Expand Up @@ -2487,8 +2490,8 @@
"""
if not self.is_complete():
raise ValueError('to be polytopal, the fan should be complete')
from sage.geometry.triangulation.point_configuration import PointConfiguration
from sage.geometry.polyhedron.constructor import Polyhedron
from sage.geometry.triangulation.point_configuration import PointConfiguration
pc = PointConfiguration(self.rays())
v_pc = [tuple(p) for p in pc]
pc_to_indices = {tuple(p):i for i, p in enumerate(pc)}
Expand Down Expand Up @@ -2757,8 +2760,10 @@
sage: fan1.is_isomorphic(fan1)
True
"""
from sage.geometry.fan_isomorphism import \
fan_isomorphic_necessary_conditions, fan_isomorphism_generator
from sage.geometry.fan_isomorphism import (
fan_isomorphic_necessary_conditions,
fan_isomorphism_generator,
)
if not fan_isomorphic_necessary_conditions(self, other):
return False
if self.lattice_dim() == 2:
Expand Down
29 changes: 16 additions & 13 deletions src/sage/geometry/lattice_polytope.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,24 +120,26 @@
# (at your option) any later version.
# https://www.gnu.org/licenses/
# ****************************************************************************
from __future__ import annotations

import os
import shlex
from collections.abc import Hashable
from copyreg import constructor as copyreg_constructor
from functools import reduce
from io import IOBase, StringIO
from subprocess import Popen, PIPE
from warnings import warn
import os
import shlex
from subprocess import PIPE, Popen
from typing import TYPE_CHECKING

import sage.geometry.abc
from sage.arith.misc import GCD as gcd
from sage.features import PythonModule
from sage.features.palp import PalpExecutable
from sage.features.databases import DatabaseReflexivePolytopes
from sage.features.palp import PalpExecutable
from sage.geometry.cone import _ambient_space_point, integral_length
from sage.geometry.point_collection import (PointCollection,
read_palp_point_collection)
from sage.geometry.toric_lattice import ToricLattice, ToricLattice_generic
from sage.geometry.convex_set import ConvexSet_compact
from sage.geometry.point_collection import PointCollection, read_palp_point_collection
from sage.geometry.toric_lattice import ToricLattice, ToricLattice_generic
from sage.matrix.constructor import matrix
from sage.misc.cachefunc import cached_method
from sage.misc.flatten import flatten
Expand All @@ -149,11 +151,9 @@
from sage.rings.rational_field import QQ
from sage.sets.set import Set_generic
from sage.structure.element import Matrix
from sage.structure.richcmp import richcmp_method, richcmp
from sage.structure.richcmp import richcmp, richcmp_method
from sage.structure.sage_object import SageObject
from sage.structure.sequence import Sequence
import sage.geometry.abc


lazy_import("sage.combinat.posets.posets", 'FinitePoset')
lazy_import("sage.geometry.hasse_diagram", 'lattice_from_incidences')
Expand All @@ -167,6 +167,9 @@
lazy_import('ppl', 'point', as_='PPL_point',
feature=PythonModule("ppl", spkg='pplpy', type='standard'))

if TYPE_CHECKING:
from sage.misc.sage_input import CoercionMode, SageInputBuilder, SageInputExpression


class SetOfAllLatticePolytopesClass(Set_generic):
def _repr_(self) -> str:
Expand Down Expand Up @@ -570,7 +573,7 @@ def __init__(self, points=None, compute_vertices=None,
self._ambient_facet_indices = tuple(ambient_facet_indices)
self._vertices = ambient.vertices(self._ambient_vertex_indices)

def _sage_input_(self, sib, coerced):
def _sage_input_(self, sib: SageInputBuilder, coerced: CoercionMode) -> SageInputExpression:
"""
Return Sage command to reconstruct ``self``.

Expand Down Expand Up @@ -4471,7 +4474,7 @@ def _repr_(self):
pass
return result

def _sage_input_(self, sib, coerced):
def _sage_input_(self, sib: SageInputBuilder, coerced: bool) -> SageInputExpression:
"""
Return Sage command to reconstruct ``self``.

Expand Down
4 changes: 3 additions & 1 deletion src/sage/geometry/point_collection.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ from sage.geometry.toric_lattice import ToricLattice
from sage.matrix.constructor import matrix
from sage.misc.latex import latex

from sage.misc.sage_input import CoercionMode, SageInputBuilder, SageInputExpression


def is_PointCollection(x):
r"""
Expand Down Expand Up @@ -172,7 +174,7 @@ cdef class PointCollection(SageObject):
self._points = tuple(points)
self._module = self._points[0].parent() if module is None else module

def _sage_input_(self, sib, coerced):
def _sage_input_(self, sib: SageInputBuilder, coerced: CoercionMode) -> SageInputExpression:
r"""
Return Sage command to reconstruct ``self``.

Expand Down
12 changes: 9 additions & 3 deletions src/sage/geometry/polyhedron/base0.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,17 @@
# (at your option) any later version.
# https://www.gnu.org/licenses/
# ****************************************************************************
from __future__ import annotations

from sage.misc.cachefunc import cached_method
from typing import TYPE_CHECKING

import sage.geometry.abc
from sage.misc.abstract_method import abstract_method
from sage.misc.cachefunc import cached_method
from sage.structure.element import Element
import sage.geometry.abc

if TYPE_CHECKING:
from sage.misc.sage_input import CoercionMode, SageInputBuilder, SageInputExpression


class Polyhedron_base0(Element, sage.geometry.abc.Polyhedron):
Expand Down Expand Up @@ -296,7 +302,7 @@ def _delete(self):
"""
self.parent().recycle(self)

def _sage_input_(self, sib, coerced):
def _sage_input_(self, sib: SageInputBuilder, coerced: CoercionMode) -> SageInputExpression:
"""
Return Sage command to reconstruct ``self``.

Expand Down
8 changes: 7 additions & 1 deletion src/sage/geometry/toric_lattice.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,9 @@
#
# https://www.gnu.org/licenses/
# ****************************************************************************
from __future__ import annotations

from typing import TYPE_CHECKING

from sage.geometry.toric_lattice_element import ToricLatticeElement
from sage.misc.lazy_import import lazy_import
Expand All @@ -162,6 +165,9 @@
from sage.rings.rational_field import QQ
from sage.structure.factory import UniqueFactory

if TYPE_CHECKING:
from sage.misc.sage_input import CoercionMode, SageInputBuilder, SageInputExpression


def is_ToricLattice(x):
r"""
Expand Down Expand Up @@ -897,7 +903,7 @@ def __init__(self, rank, name, dual_name, latex_name, latex_dual_name):
self._latex_name = latex_name
self._latex_dual_name = latex_dual_name

def _sage_input_(self, sib, coerced):
def _sage_input_(self, sib: SageInputBuilder, coerced: CoercionMode) -> SageInputExpression:
r"""
Return Sage command to reconstruct ``self``.

Expand Down
3 changes: 2 additions & 1 deletion src/sage/matrix/matrix1.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ from cpython.sequence cimport PySequence_Fast
import sage.modules.free_module
from sage.structure.coerce cimport coercion_model

from sage.misc.sage_input import CoercionMode, SageInputBuilder, SageInputExpression

cdef class Matrix(Matrix0):
###################################################
Expand Down Expand Up @@ -622,7 +623,7 @@ cdef class Matrix(Matrix0):
matrix._sage_object = self
return matrix

def _sage_input_(self, sib, coerce):
def _sage_input_(self, sib: SageInputBuilder, coerced: CoercionMode) -> SageInputExpression:
r"""
Produce an expression which will reproduce this value when evaluated.

Expand Down
Loading
Loading