Skip to content

Commit 1e6cd50

Browse files
author
Release Manager
committed
gh-36072: small cleanup of triangulation/base.pyx <!-- ^^^^^ Please provide a concise, informative and self-explanatory title. Don't put issue numbers in there, do this in the PR body below. For example, instead of "Fixes #1234" use "Introduce new method to calculate 1+1" --> <!-- Describe your changes here in detail --> This fixes some suggestions of cython-lint in the modified file. <!-- Why is this change required? What problem does it solve? --> <!-- If this PR resolves an open issue, please link to it here. For example "Fixes #12345". --> <!-- If your change requires a documentation PR, please link it appropriately. --> ### 📝 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 - #12345: short description why this is a dependency - #34567: ... --> <!-- If you're unsure about any of these, don't hesitate to ask. We're here to help! --> URL: #36072 Reported by: Frédéric Chapoton Reviewer(s): Matthias Köppe
2 parents ddcfc9a + 3de27ca commit 1e6cd50

File tree

1 file changed

+16
-44
lines changed

1 file changed

+16
-44
lines changed

src/sage/geometry/triangulation/base.pyx

Lines changed: 16 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ AUTHORS:
1818
#
1919
# Distributed under the terms of the GNU General Public License (GPL)
2020
#
21-
# http://www.gnu.org/licenses/
21+
# https://www.gnu.org/licenses/
2222
########################################################################
2323

2424
from sage.misc.fast_methods cimport hash_by_id
@@ -76,7 +76,6 @@ cdef class Point(SageObject):
7676
cdef object _point_configuration
7777
cdef object _reduced_affine_vector, _reduced_projective_vector
7878

79-
8079
def __init__(self, point_configuration, i, projective, affine, reduced):
8180
r"""
8281
Construct a :class:`Point`.
@@ -129,7 +128,6 @@ cdef class Point(SageObject):
129128
"""
130129
return self._point_configuration
131130

132-
133131
def __iter__(self):
134132
r"""
135133
Iterate through the affine ambient space coordinates of the point.
@@ -160,7 +158,6 @@ cdef class Point(SageObject):
160158
"""
161159
return len(self._affine)
162160

163-
164161
cpdef index(self):
165162
"""
166163
Return the index of the point in the point configuration.
@@ -175,7 +172,6 @@ cdef class Point(SageObject):
175172
"""
176173
return self._index
177174

178-
179175
cpdef projective(self):
180176
r"""
181177
Return the projective coordinates of the point in the ambient space.
@@ -202,7 +198,6 @@ cdef class Point(SageObject):
202198
"""
203199
return self._projective
204200

205-
206201
cpdef affine(self):
207202
r"""
208203
Return the affine coordinates of the point in the ambient space.
@@ -229,7 +224,6 @@ cdef class Point(SageObject):
229224
"""
230225
return self._affine
231226

232-
233227
cpdef reduced_affine(self):
234228
r"""
235229
Return the affine coordinates of the point on the hyperplane
@@ -257,7 +251,6 @@ cdef class Point(SageObject):
257251
"""
258252
return self._reduced_affine
259253

260-
261254
cpdef reduced_projective(self):
262255
r"""
263256
Return the projective coordinates of the point on the hyperplane
@@ -285,7 +278,6 @@ cdef class Point(SageObject):
285278
"""
286279
return tuple(self._reduced_affine)+(1,)
287280

288-
289281
cpdef reduced_affine_vector(self):
290282
"""
291283
Return the affine coordinates of the point on the hyperplane
@@ -313,7 +305,6 @@ cdef class Point(SageObject):
313305
"""
314306
return self._reduced_affine_vector
315307

316-
317308
cpdef reduced_projective_vector(self):
318309
"""
319310
Return the affine coordinates of the point on the hyperplane
@@ -359,7 +350,7 @@ cdef class Point(SageObject):
359350
sage: p._repr_()
360351
'P(0, 0)'
361352
"""
362-
return 'P'+str(self._affine)
353+
return 'P' + str(self._affine)
363354

364355

365356
########################################################################
@@ -398,15 +389,13 @@ cdef class PointConfiguration_base(Parent):
398389
self._init_points(points)
399390
self._is_affine = defined_affine
400391

401-
402392
cdef tuple _pts
403393
cdef int _ambient_dim
404394
cdef int _dim
405395
cdef object _base_ring
406396
cdef bint _is_affine
407397
cdef object _reduced_affine_vector_space, _reduced_projective_vector_space
408398

409-
410399
cdef _init_points(self, tuple projective_points):
411400
"""
412401
Internal method to determine coordinates of points.
@@ -449,20 +438,20 @@ cdef class PointConfiguration_base(Parent):
449438
else:
450439
raise NotImplementedError # TODO
451440

452-
if n>1:
441+
if n > 1:
453442
# shift first point to origin
454-
red = matrix([ aff.column(i)-aff.column(0) for i in range(n) ]).transpose()
443+
red = matrix([aff.column(i)-aff.column(0) for i in range(n)]).transpose()
455444
# pick linearly independent rows
456-
red = matrix([ red.row(i) for i in red.pivot_rows()])
445+
red = matrix([red.row(i) for i in red.pivot_rows()])
457446
else:
458-
red = matrix(0,1)
447+
red = matrix(0, 1)
459448
self._dim = red.nrows()
460449

461450
from sage.modules.free_module import VectorSpace
462451
self._reduced_affine_vector_space = VectorSpace(self._base_ring.fraction_field(), self._dim)
463452
self._reduced_projective_vector_space = VectorSpace(self._base_ring.fraction_field(), self._dim+1)
464453
self._pts = tuple([Point(self, i, proj.column(i),
465-
aff.column(i), red.column(i))
454+
aff.column(i), red.column(i))
466455
for i in range(n)])
467456

468457
def __hash__(self):
@@ -497,7 +486,6 @@ cdef class PointConfiguration_base(Parent):
497486
"""
498487
return self._reduced_affine_vector_space
499488

500-
501489
cpdef reduced_projective_vector_space(self):
502490
"""
503491
Return the vector space that is spanned by the homogeneous
@@ -519,7 +507,6 @@ cdef class PointConfiguration_base(Parent):
519507
"""
520508
return self._reduced_projective_vector_space
521509

522-
523510
cpdef ambient_dim(self):
524511
"""
525512
Return the dimension of the ambient space of the point
@@ -537,11 +524,9 @@ cdef class PointConfiguration_base(Parent):
537524
"""
538525
return self._ambient_dim
539526

540-
541527
cpdef dim(self):
542528
"""
543-
Return the actual dimension of the point
544-
configuration.
529+
Return the actual dimension of the point configuration.
545530
546531
See also :meth:`ambient_dim`
547532
@@ -555,7 +540,6 @@ cdef class PointConfiguration_base(Parent):
555540
"""
556541
return self._dim
557542

558-
559543
cpdef base_ring(self):
560544
r"""
561545
Return the base ring, that is, the ring containing the
@@ -581,10 +565,9 @@ cdef class PointConfiguration_base(Parent):
581565
"""
582566
return self._base_ring
583567

584-
585568
cpdef bint is_affine(self):
586569
"""
587-
Whether the configuration is defined by affine points.
570+
Return whether the configuration is defined by affine points.
588571
589572
OUTPUT:
590573
@@ -603,7 +586,6 @@ cdef class PointConfiguration_base(Parent):
603586
"""
604587
return self._is_affine
605588

606-
607589
def _assert_is_affine(self):
608590
"""
609591
Raise a ``ValueError`` if the point configuration is not
@@ -622,7 +604,6 @@ cdef class PointConfiguration_base(Parent):
622604
if not self.is_affine():
623605
raise ValueError('The point configuration contains projective points.')
624606

625-
626607
def __getitem__(self, i):
627608
"""
628609
Return the ``i``-th point.
@@ -651,7 +632,6 @@ cdef class PointConfiguration_base(Parent):
651632
"""
652633
return self._pts[i]
653634

654-
655635
cpdef n_points(self):
656636
"""
657637
Return the number of points.
@@ -673,14 +653,13 @@ cdef class PointConfiguration_base(Parent):
673653
"""
674654
return len(self._pts)
675655

676-
677656
cpdef points(self):
678657
"""
679658
Return a list of the points.
680659
681660
OUTPUT:
682661
683-
Returns a list of the points. See also the :meth:`__iter__`
662+
A list of the points. See also the :meth:`__iter__`
684663
method, which returns the corresponding generator.
685664
686665
EXAMPLES::
@@ -699,7 +678,6 @@ cdef class PointConfiguration_base(Parent):
699678
"""
700679
return self._pts
701680

702-
703681
def point(self, i):
704682
"""
705683
Return the i-th point of the configuration.
@@ -753,10 +731,9 @@ cdef class PointConfiguration_base(Parent):
753731
"""
754732
return len(self._pts)
755733

756-
757734
cpdef simplex_to_int(self, simplex):
758735
r"""
759-
Returns an integer that uniquely identifies the given simplex.
736+
Return an integer that uniquely identifies the given simplex.
760737
761738
See also the inverse method :meth:`int_to_simplex`.
762739
@@ -790,19 +767,18 @@ cdef class PointConfiguration_base(Parent):
790767
cdef int k = 1
791768
cdef int n = self.n_points()
792769
cdef int d = len(simplex)
793-
assert d==self.dim()+1
770+
assert d == self.dim()+1
794771
cdef int i, j
795-
for i in range(1,d+1):
772+
for i in range(1, d+1):
796773
l = simplex[i-1]+1
797-
for j in range(k,l):
798-
s += binomial(n-j,d-i)
774+
for j in range(k, l):
775+
s += binomial(n-j, d-i)
799776
k = l+1
800777
return s
801778

802-
803779
cpdef int_to_simplex(self, int s):
804780
r"""
805-
Reverses the enumeration of possible simplices in
781+
Reverse the enumeration of possible simplices in
806782
:meth:`simplex_to_int`.
807783
808784
The enumeration is compatible with [PUNTOS]_.
@@ -930,7 +906,6 @@ cdef class ConnectedTriangulationsIterator(SageObject):
930906
931907
cdef triangulations_ptr _tp
932908
933-
934909
def __cinit__(self):
935910
"""
936911
The Cython constructor.
@@ -944,7 +919,6 @@ cdef class ConnectedTriangulationsIterator(SageObject):
944919
"""
945920
self._tp = NULL
946921
947-
948922
def __init__(self, point_configuration, seed=None, star=None, fine=False):
949923
r"""
950924
The Python constructor.
@@ -978,14 +952,12 @@ cdef class ConnectedTriangulationsIterator(SageObject):
978952
enumerated_simplices_seed,
979953
point_configuration.bistellar_flips())
980954
981-
982955
def __dealloc__(self):
983956
r"""
984957
The Cython destructor.
985958
"""
986959
delete_triangulations(self._tp)
987960
988-
989961
def __iter__(self):
990962
r"""
991963
The iterator interface: Start iterating.

0 commit comments

Comments
 (0)