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
2 changes: 1 addition & 1 deletion src/sage/categories/primer.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@

sage: A = random_matrix(ZZ, 6, 3, x=7) # needs sage.modules
sage: L = LatticePolytope(A.rows()) # needs sage.geometry.polyhedron sage.modules
sage: L.npoints() # oops! # random # needs sage.geometry.polyhedron sage.modules
sage: L.n_points() # oops! # random # needs sage.geometry.polyhedron sage.modules
37

- How to ensure robustness?
Expand Down
2 changes: 1 addition & 1 deletion src/sage/combinat/quickref.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@

sage: points = random_matrix(ZZ, 6, 3, x=7).rows() # needs sage.modules
sage: L = LatticePolytope(points) # needs sage.geometry.polyhedron sage.modules
sage: L.npoints(); L.plot3d() # random # needs sage.geometry.polyhedron sage.modules sage.plot
sage: L.n_points(); L.plot3d() # random # needs sage.geometry.polyhedron sage.modules sage.plot

:ref:`Root systems, Coxeter and Weyl groups <sage.combinat.root_system.all>`::

Expand Down
2 changes: 1 addition & 1 deletion src/sage/combinat/tutorial.py
Original file line number Diff line number Diff line change
Expand Up @@ -1635,7 +1635,7 @@
M(4, 2, 3),
M(5, 2, 3)
in 3-d lattice M
sage: L.npoints() # random
sage: L.n_points() # random
11

This polytope can be visualized in 3D with ``L.plot3d()`` (see
Expand Down
48 changes: 29 additions & 19 deletions src/sage/geometry/cone.py
Original file line number Diff line number Diff line change
Expand Up @@ -1061,20 +1061,30 @@ def lattice_dim(self):

ambient_dim = lattice_dim

def nrays(self):
def n_rays(self) -> int:
r"""
Return the number of rays of ``self``.

OUTPUT: integer

EXAMPLES::

sage: c = Cone([(1,0), (0,1)])
sage: c.n_rays()
2

TESTS:

The old method name is kept as an alias::

sage: c = Cone([(1,0), (0,1)])
sage: c.nrays()
2
"""
return len(self._rays)

nrays = n_rays

def plot(self, **options):
r"""
Plot ``self``.
Expand Down Expand Up @@ -1491,7 +1501,7 @@ def __init__(self, rays=None, lattice=None,
if ambient is None:
superinit(rays, lattice)
self._ambient = self
self._ambient_ray_indices = tuple(range(self.nrays()))
self._ambient_ray_indices = tuple(range(self.n_rays()))
else:
self._ambient = ambient
self._ambient_ray_indices = tuple(ambient_ray_indices)
Expand Down Expand Up @@ -2028,7 +2038,7 @@ def _sort_faces(self, faces):
"""
faces = tuple(faces)
if len(faces) > 1: # Otherwise there is nothing to sort
if faces[0].nrays() == 1:
if faces[0].n_rays() == 1:
faces = tuple(sorted(faces,
key=lambda f: f._ambient_ray_indices))
elif faces[0].dim() == self.dim() - 1 and \
Expand Down Expand Up @@ -2950,7 +2960,7 @@ def incidence_matrix(self):
Integer Ring
"""
normals = self.facet_normals()
incidence_matrix = matrix(ZZ, self.nrays(),
incidence_matrix = matrix(ZZ, self.n_rays(),
len(normals), 0)

for Hindex, normal in enumerate(self.facet_normals()):
Expand Down Expand Up @@ -3259,7 +3269,7 @@ def is_simplicial(self) -> bool:
sage: cone2.is_simplicial()
False
"""
return self.nrays() == self.dim()
return self.n_rays() == self.dim()

@cached_method
def is_smooth(self) -> bool:
Expand Down Expand Up @@ -3294,7 +3304,7 @@ def is_smooth(self) -> bool:
"""
if not self.is_simplicial():
return False
return self.rays().matrix().elementary_divisors() == [1] * self.nrays()
return self.rays().matrix().elementary_divisors() == [1] * self.n_rays()

def is_empty(self):
"""
Expand All @@ -3321,10 +3331,10 @@ def is_trivial(self) -> bool:
sage: c0 = cones.trivial(3)
sage: c0.is_trivial()
True
sage: c0.nrays()
sage: c0.n_rays()
0
"""
return self.nrays() == 0
return self.n_rays() == 0

is_compact = is_trivial

Expand Down Expand Up @@ -3438,7 +3448,7 @@ def plot(self, **options):
deg = self.lattice().degree()
tp = ToricPlotter(options, deg, self.rays())
# Modify ray labels to match the ambient cone or fan.
tp.ray_label = label_list(tp.ray_label, self.nrays(), deg <= 2,
tp.ray_label = label_list(tp.ray_label, self.n_rays(), deg <= 2,
self.ambient_ray_indices())
result = tp.plot_lattice() + tp.plot_generators()
# To deal with non-strictly convex cones we separate rays and labels.
Expand Down Expand Up @@ -3683,7 +3693,7 @@ def solid_restriction(self):
the original::

sage: K = random_cone(max_ambient_dim=6)
sage: K.solid_restriction().nrays() == K.nrays()
sage: K.solid_restriction().n_rays() == K.n_rays()
True

The solid restriction of a cone has the same lineality as the
Expand Down Expand Up @@ -4320,7 +4330,7 @@ def semigroup_generators(self):
if not self.is_simplicial():
from sage.geometry.triangulation.point_configuration \
import PointConfiguration
origin = self.nrays() # last one in pc
origin = self.n_rays() # last one in pc
pc = PointConfiguration(tuple(self.rays()) + (N(0),), star=origin)
triangulation = pc.triangulate()
subcones = ( Cone(( self.ray(i) for i in simplex if i != origin ),
Expand Down Expand Up @@ -4360,7 +4370,7 @@ def Hilbert_basis(self):

- a
:class:`~sage.geometry.point_collection.PointCollection`. The
rays of ``self`` are the first ``self.nrays()`` entries.
rays of ``self`` are the first ``self.n_rays()`` entries.

EXAMPLES:

Expand Down Expand Up @@ -6473,7 +6483,7 @@ def random_cone(lattice=None, min_ambient_dim=0, max_ambient_dim=None,
Likewise for the number of rays when ``min_rays == max_rays``::

sage: K = random_cone(min_rays=3, max_rays=3)
sage: K.nrays()
sage: K.n_rays()
3

If we specify a lattice, then the returned cone will live in it::
Expand Down Expand Up @@ -6504,7 +6514,7 @@ def random_cone(lattice=None, min_ambient_dim=0, max_ambient_dim=None,
....: strictly_convex=False, solid=True)
sage: 4 <= K.lattice_dim() and K.lattice_dim() <= 7
True
sage: 2 <= K.nrays() and K.nrays() <= 10
sage: 2 <= K.n_rays() and K.n_rays() <= 10
True
sage: K.is_strictly_convex()
False
Expand All @@ -6526,7 +6536,7 @@ def random_cone(lattice=None, min_ambient_dim=0, max_ambient_dim=None,
....: min_rays=3, max_rays=4)
sage: 5 <= K.lattice_dim() and K.lattice_dim() <= 8
True
sage: 3 <= K.nrays() and K.nrays() <= 4
sage: 3 <= K.n_rays() and K.n_rays() <= 4
True

Ensure that an exception is raised when either lower bound is greater
Expand Down Expand Up @@ -6606,7 +6616,7 @@ def random_cone(lattice=None, min_ambient_dim=0, max_ambient_dim=None,
sage: _initial_seed = initial_seed()
sage: set_random_seed(8)
sage: K = random_cone(max_ambient_dim=3, min_rays=7)
sage: K.nrays() >= 7
sage: K.n_rays() >= 7
True
sage: K.lattice_dim()
3
Expand Down Expand Up @@ -6845,8 +6855,8 @@ def is_valid(K):
else:
if K.lattice() is not lattice:
return False
return all([K.nrays() >= min_rays,
max_rays is None or K.nrays() <= max_rays,
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,
strictly_convex is None or
K.is_strictly_convex() == strictly_convex])
Expand Down Expand Up @@ -6910,7 +6920,7 @@ def is_valid(K):
# mangle what we have, we just start over if we get a cone
# that won't work.
#
while r > K.nrays() and not K.is_full_space():
while r > K.n_rays() and not K.is_full_space():
rays.append(L.random_element())
K = Cone(rays, lattice=L)
rays = list(K.rays()) # Avoid re-normalizing next time around
Expand Down
12 changes: 6 additions & 6 deletions src/sage/geometry/cone_critical_angles.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ def gevp_licis(G):
sage: from sage.geometry.cone_critical_angles import gevp_licis
sage: K = cones.nonnegative_orthant(3)
sage: G = matrix.column(K.rays())
sage: len(list(gevp_licis(G))) == 2^(K.nrays()) - 1
sage: len(list(gevp_licis(G))) == 2^(K.n_rays()) - 1
True

TESTS:
Expand Down Expand Up @@ -647,8 +647,8 @@ def compute_gevp_M(gs, hs):
sage: hs = [h.change_ring(QQ) for h in Q]
sage: M = compute_gevp_M(gs, hs)[0]
sage: all( M[i][j] == gs[i].inner_product(hs[j])
....: for i in range(P.nrays())
....: for j in range(Q.nrays()) )
....: for i in range(P.n_rays())
....: for j in range(Q.n_rays()) )
True

TESTS:
Expand All @@ -670,7 +670,7 @@ def compute_gevp_M(gs, hs):
sage: hs = [h.change_ring(QQ) for h in Q]
sage: M = compute_gevp_M(gs,hs)[0]
sage: f = lambda i,j: gs[i].inner_product(hs[j])
sage: expected_M = matrix(QQ, P.nrays(), Q.nrays(), f)
sage: expected_M = matrix(QQ, P.n_rays(), Q.n_rays(), f)
sage: M == expected_M
True
sage: G = matrix.column(gs)
Expand Down Expand Up @@ -954,11 +954,11 @@ def max_angle(P, Q, exact, epsilon):

for I in G_index_sets:
G_I = G.matrix_from_columns(I)
I_complement = [i for i in range(P.nrays()) if i not in I]
I_complement = [i for i in range(P.n_rays()) if i not in I]
G_I_c_T = G.matrix_from_columns(I_complement).transpose()

for J in H_index_sets:
J_complement = [j for j in range(Q.nrays()) if j not in J]
J_complement = [j for j in range(Q.n_rays()) if j not in J]
H_J = H.matrix_from_columns(J)
H_J_c_T = H.matrix_from_columns(J_complement).transpose()

Expand Down
Loading
Loading