Skip to content
Closed
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
39 changes: 6 additions & 33 deletions src/sage/geometry/cone.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,6 @@
from sage.combinat.posets.posets import FinitePoset
from sage.geometry.point_collection import PointCollection
from sage.geometry.polyhedron.constructor import Polyhedron
from sage.geometry.polyhedron.base import is_Polyhedron
from sage.geometry.hasse_diagram import lattice_from_incidences
from sage.geometry.toric_lattice import (ToricLattice, is_ToricLattice,
is_ToricLatticeQuotient)
Expand Down Expand Up @@ -243,31 +242,6 @@
feature=PythonModule("ppl", spkg="pplpy", type="standard"))


def is_Cone(x):
r"""
Check if ``x`` is a cone.

INPUT:

- ``x`` -- anything.

OUTPUT:

- ``True`` if ``x`` is a cone and ``False`` otherwise.

EXAMPLES::

sage: from sage.geometry.cone import is_Cone
sage: is_Cone(1)
False
sage: quadrant = Cone([(1,0), (0,1)])
sage: quadrant
2-d cone in 2-d lattice N
sage: is_Cone(quadrant)
True
"""
return isinstance(x, ConvexRationalPolyhedralCone)


def Cone(rays, lattice=None, check=True, normalize=True):
r"""
Expand Down Expand Up @@ -439,7 +413,7 @@ def Cone(rays, lattice=None, check=True, normalize=True):
0-d cone in 2-d lattice N
"""
# Cone from Polyhedron
if is_Polyhedron(rays):
if isinstance(rays, sage.geometry.abc.Polyhedron):
polyhedron = rays
if lattice is None:
lattice = ToricLattice(polyhedron.ambient_dim())
Expand Down Expand Up @@ -1894,7 +1868,7 @@ def cartesian_product(self, other, lattice=None):
N+N(0, 1)
in 2-d lattice N+N
"""
assert is_Cone(other)
assert isinstance(other, sage.geometry.abc.ConvexRationalPolyhedralCone)
rc = super().cartesian_product(other, lattice)
return ConvexRationalPolyhedralCone(rc.rays(), rc.lattice())

Expand Down Expand Up @@ -1952,7 +1926,7 @@ def __richcmp__(self, right, op):
sage: c2 is c3
False
"""
if is_Cone(right):
if isinstance(right, sage.geometry.abc.ConvexRationalPolyhedralCone):
# We don't care about particular type of right in this case
return richcmp((self.lattice(), self.rays()),
(right.lattice(), right.rays()), op)
Expand Down Expand Up @@ -2413,7 +2387,7 @@ def embed(self, cone):
ValueError: 2-d cone in 3-d lattice N is not a face
of 3-d cone in 3-d lattice N!
"""
assert is_Cone(cone)
assert isinstance(cone, sage.geometry.abc.ConvexRationalPolyhedralCone)
if cone.ambient() is self:
return cone
if self.is_strictly_convex():
Expand Down Expand Up @@ -2935,7 +2909,7 @@ def facet_of(self):
L = self._ambient._face_lattice_function()
H = L.hasse_diagram()
return self._sort_faces(
f for f in H.neighbors_out(L(self)) if is_Cone(f))
f for f in H.neighbors_out(L(self)) if isinstance(f, sage.geometry.abc.ConvexRationalPolyhedralCone))

def facets(self):
r"""
Expand Down Expand Up @@ -6387,9 +6361,8 @@ def random_cone(lattice=None, min_ambient_dim=0, max_ambient_dim=None,
It's hard to test the output of a random process, but we can at
least make sure that we get a cone back::

sage: from sage.geometry.cone import is_Cone
sage: K = random_cone(max_ambient_dim=6, max_rays=10)
sage: is_Cone(K)
sage: isinstance(K, sage.geometry.abc.ConvexRationalPolyhedralCone)
True

The upper/lower bounds are respected::
Expand Down
12 changes: 5 additions & 7 deletions src/sage/geometry/fan.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,6 @@
Cone,
ConvexRationalPolyhedralCone,
IntegralRayCollection,
is_Cone,
normalize_rays)
from sage.geometry.hasse_diagram import lattice_from_incidences
from sage.geometry.point_collection import PointCollection
Expand Down Expand Up @@ -571,7 +570,7 @@ def result():
cones = ((), )
rays = ()
return result()
if is_Cone(cones[0]):
if isinstance(cones[0], sage.geometry.abc.ConvexRationalPolyhedralCone):
# Construct the fan from Cone objects
if lattice is None:
lattice = cones[0].lattice()
Expand Down Expand Up @@ -749,11 +748,11 @@ def FaceFan(polytope, lattice=None):
ValueError: face fans are defined only for
polytopes containing the origin as an interior point!
"""
from sage.geometry.lattice_polytope import is_LatticePolytope

interior_point_error = ValueError(
"face fans are defined only for polytopes containing "
"the origin as an interior point!")
if is_LatticePolytope(polytope):
if isinstance(polytope, sage.geometry.abc.LatticePolytope):
if any(d <= 0 for d in polytope.distances([0] * polytope.dim())):
raise interior_point_error
cones = (f.ambient_vertex_indices() for f in polytope.facets())
Expand Down Expand Up @@ -843,8 +842,7 @@ def NormalFan(polytope, lattice=None):
"""
dimension_error = ValueError(
'the normal fan is only defined for full-dimensional polytopes')
from sage.geometry.lattice_polytope import is_LatticePolytope
if is_LatticePolytope(polytope):
if isinstance(polytope, sage.geometry.abc.LatticePolytope):
if polytope.dim() != polytope.lattice_dim():
raise dimension_error
rays = polytope.facet_normals()
Expand Down Expand Up @@ -2425,7 +2423,7 @@ def embed(self, cone):
ValueError: 2-d cone in 3-d lattice N does not belong
to Rational polyhedral fan in 3-d lattice N!
"""
if not is_Cone(cone):
if not isinstance(cone, sage.geometry.abc.ConvexRationalPolyhedralCone):
raise TypeError("%s is not a cone!" % cone)
if cone.ambient() is self:
return cone
Expand Down
3 changes: 1 addition & 2 deletions src/sage/geometry/hyperplane_arrangement/hyperplane.py
Original file line number Diff line number Diff line change
Expand Up @@ -460,9 +460,8 @@ def intersection(self, other):
sage: h.intersection(polytopes.cube())
A 2-dimensional polyhedron in QQ^3 defined as the convex hull of 3 vertices
"""
from sage.geometry.polyhedron.base import is_Polyhedron
from sage.geometry.polyhedron.constructor import Polyhedron
if not is_Polyhedron(other):
if not isinstance(other, sage.geometry.abc.Polyhedron):
try:
other = other.polyhedron()
except AttributeError:
Expand Down
26 changes: 0 additions & 26 deletions src/sage/geometry/lattice_polytope.py
Original file line number Diff line number Diff line change
Expand Up @@ -463,32 +463,6 @@ def ReflexivePolytopes(dim):
return _rp[dim]


def is_LatticePolytope(x):
r"""
Check if ``x`` is a lattice polytope.

INPUT:

- ``x`` -- anything.

OUTPUT:

- ``True`` if ``x`` is a :class:`lattice polytope <LatticePolytopeClass>`,
``False`` otherwise.

EXAMPLES::

sage: from sage.geometry.lattice_polytope import is_LatticePolytope
sage: is_LatticePolytope(1)
False
sage: p = LatticePolytope([(1,0), (0,1), (-1,-1)])
sage: p # needs palp
2-d reflexive polytope #0 in 2-d lattice M
sage: is_LatticePolytope(p)
True
"""
return isinstance(x, LatticePolytopeClass)

@richcmp_method
class LatticePolytopeClass(ConvexSet_compact, Hashable, sage.geometry.abc.LatticePolytope):
r"""
Expand Down
3 changes: 1 addition & 2 deletions src/sage/geometry/newton_polygon.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@

from sage.rings.infinity import Infinity
from sage.geometry.polyhedron.constructor import Polyhedron
from sage.geometry.polyhedron.base import is_Polyhedron


class NewtonPolygon_element(Element):
Expand Down Expand Up @@ -716,7 +715,7 @@ def _element_constructor_(self, arg, sort_slopes=True, last_slope=Infinity):
sage: NewtonPolygon(1)
Finite Newton polygon with 1 vertex: (0, 0)
"""
if is_Polyhedron(arg):
if isinstance(arg, sage.geometry.abc.Polyhedron):
return self.element_class(arg, parent=self)
if arg == 0:
polyhedron = Polyhedron(base_ring=self.base_ring(), ambient_dim=2)
Expand Down
3 changes: 1 addition & 2 deletions src/sage/geometry/polyhedral_complex.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@
from copy import copy
from sage.topology.cell_complex import GenericCellComplex
from sage.geometry.polyhedron.constructor import Polyhedron
from sage.geometry.polyhedron.base import is_Polyhedron
from sage.modules.free_module_element import vector
from sage.rings.integer_ring import ZZ
from sage.graphs.graph import Graph
Expand Down Expand Up @@ -308,7 +307,7 @@ def __init__(self, maximal_cells=None, backend=None, maximality_check=True,
ambient_dim = next(iter(cells_dict[self._dim])).ambient_dim()
self._ambient_dim = ambient_dim
self._maximal_cells = cells_dict
if not all((is_Polyhedron(cell) and
if not all((isinstance(cell, sage.geometry.abc.Polyhedron) and
cell.ambient_dim() == self._ambient_dim)
for cell in self.maximal_cell_iterator()):
raise ValueError("the given cells are not polyhedra " +
Expand Down
26 changes: 0 additions & 26 deletions src/sage/geometry/polyhedron/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,32 +56,6 @@
#########################################################################


#########################################################################
def is_Polyhedron(X):
"""
Test whether ``X`` is a Polyhedron.

INPUT:

- ``X`` -- anything.

OUTPUT:

Boolean.

EXAMPLES::

sage: p = polytopes.hypercube(2)
sage: from sage.geometry.polyhedron.base import is_Polyhedron
sage: is_Polyhedron(p)
True
sage: is_Polyhedron(123456)
False
"""
return isinstance(X, Polyhedron_base)


#########################################################################
class Polyhedron_base(Polyhedron_base7):
"""
Base class for Polyhedron objects
Expand Down
4 changes: 1 addition & 3 deletions src/sage/geometry/polyhedron/parent.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@
from sage.categories.fields import Fields
from sage.categories.rings import Rings
from sage.categories.modules import Modules

from sage.geometry.polyhedron.base import is_Polyhedron
from .representation import Inequality, Equation, Vertex, Ray, Line


Expand Down Expand Up @@ -693,7 +691,7 @@ def convert_base_ring_Hrep(lstlst):
if convert and Vrep:
Vrep = [convert_base_ring(_) for _ in Vrep]
return self.element_class(self, Vrep, Hrep, **kwds)
if nargs == 1 and is_Polyhedron(args[0]):
if nargs == 1 and isinstance(args[0], sage.geometry.abc.Polyhedron):
copy = kwds.pop('copy', args[0].parent() is not self)
mutable = kwds.pop('mutable', False)

Expand Down
2 changes: 1 addition & 1 deletion src/sage/schemes/toric/variety.py
Original file line number Diff line number Diff line change
Expand Up @@ -2667,7 +2667,7 @@ def _orbit_closure_projection(self, cone, x):
# TODO: make the following work nicely.
# if x in cone.lattice():
# return quot(x)
# assert is_Cone(x)
# assert x is ConvexRationalPolyhedralCone object
# return Cone(x.rays(), lattice=quot)

def orbit_closure(self, cone):
Expand Down