Skip to content

Commit f41abf6

Browse files
author
Release Manager
committed
Trac #34759: some details in filtered simplicial complexes
- some pep8 changes - fix details in documentation URL: https://trac.sagemath.org/34759 Reported by: chapoton Ticket author(s): Frédéric Chapoton Reviewer(s): John Palmieri
2 parents dfc299b + 71cc4e9 commit f41abf6

File tree

1 file changed

+16
-15
lines changed

1 file changed

+16
-15
lines changed

src/sage/topology/filtered_simplicial_complex.py

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@
9090
from sage.rings.infinity import infinity
9191
from sage.misc.cachefunc import cached_method
9292

93+
9394
class FilteredSimplicialComplex(SageObject):
9495
r"""
9596
Define a filtered complex.
@@ -321,7 +322,7 @@ def filtration(self, s, filtration_value=None):
321322
322323
If ``filtration_value`` is set, this function inserts the
323324
simplex into the complex with the specified value.
324-
See documentation of ``insert`` for more details.
325+
See documentation of :meth:`insert` for more details.
325326
326327
EXAMPLES::
327328
@@ -338,7 +339,7 @@ def filtration(self, s, filtration_value=None):
338339
else:
339340
self._insert(s, filtration_value)
340341

341-
def prune(self,threshold):
342+
def prune(self, threshold):
342343
r"""
343344
Return a copy of the filtered complex, where simplices above
344345
the threshold value have been removed.
@@ -367,7 +368,7 @@ def prune(self,threshold):
367368

368369
return result_complex
369370

370-
@cached_method(key=lambda self,f,s,v:(f,s))
371+
@cached_method(key=lambda self, f, s, v: (f, s))
371372
def _persistent_homology(self, field=2, strict=True, verbose=False):
372373
"""
373374
Compute the homology intervals of the complex.
@@ -445,7 +446,7 @@ def key(s):
445446
# Initialize data structures for the algo
446447
self._marked = [False] * n
447448
self._T = [None] * n
448-
intervals = [[] for i in range(self._dimension+1)]
449+
intervals = [[] for i in range(self._dimension + 1)]
449450
self.pairs = []
450451

451452
self._strict = strict
@@ -491,7 +492,7 @@ def _add_interval(self, s, t, intervals):
491492
Add a new interval (i.e. homology element).
492493
493494
This method should not be called by users, it is used in
494-
the ``_compute_persistence`` method. The simplex of
495+
the :meth:`_persistent_homology` method. The simplex of
495496
death may be ``None``, in which case the interval is infinite.
496497
497498
INPUT:
@@ -544,7 +545,7 @@ def _remove_pivot_rows(self, s, simplices):
544545
545546
This method implements the subroutine of the same name
546547
in [ZC2005]_. This method should not be called by users,
547-
it is used in the ``compute_persistence`` method.
548+
it is used in the :meth:`_persistent_homology` method.
548549
549550
TESTS::
550551
@@ -565,11 +566,11 @@ def _remove_pivot_rows(self, s, simplices):
565566
return d
566567

567568
# Initialize the boundary chain
568-
for (i, f) in enumerate(s.faces()):
569+
for i, f in enumerate(s.faces()):
569570
d += (-1)**i * self._chaingroup(f)
570571

571572
# Remove all unmarked elements
572-
for (s, x_s) in d:
573+
for s, x_s in d:
573574
j = self._index_of_simplex[s]
574575
if not self._marked[j]:
575576
d = d - x_s * self._chaingroup(s)
@@ -586,7 +587,7 @@ def _remove_pivot_rows(self, s, simplices):
586587

587588
c = self._T[max_index][1]
588589
q = c[t]
589-
d = d - ((q**(-1))*c)
590+
d = d - ((q**(-1)) * c)
590591

591592
return d
592593

@@ -595,8 +596,8 @@ def _max_index(self, d):
595596
Return the maximal index of all simplices with nonzero
596597
coefficient in ``d``.
597598
598-
This method is called in ``_remove_pivot_rows`` and
599-
``compute_persistence``. It should not be called by users
599+
This method is called in :meth:`_remove_pivot_rows` and
600+
:meth:`_persistent_homology`. It should not be called by users
600601
outside of those methods.
601602
602603
TESTS::
@@ -611,7 +612,7 @@ def _max_index(self, d):
611612
6
612613
"""
613614
currmax = -1
614-
for (s, x_s) in d:
615+
for s, x_s in d:
615616
j = self._index_of_simplex[s]
616617
if j > currmax:
617618
currmax = j
@@ -664,7 +665,7 @@ def betti_number(self, k, a, b, field=2, strict=True, verbose=None):
664665
persistent homology computation; the default is the verbosity
665666
of ``self``
666667
667-
The Betti number ``\beta_k^{a,a+b}`` counts the number of
668+
The Betti number `\beta_k^{a,a+b}` counts the number of
668669
homology elements which are alive throughout the whole
669670
duration ``[a, a+b]``.
670671
@@ -686,7 +687,7 @@ def betti_number(self, k, a, b, field=2, strict=True, verbose=None):
686687
if verbose is None:
687688
verbose = self._verbose
688689
intervals = self._persistent_homology(field, strict, verbose=verbose)
689-
return Integer(sum(1 for (i, j) in intervals[k]
690+
return Integer(sum(1 for i, j in intervals[k]
690691
if (i <= a and a + b < j) and a >= 0))
691692

692693
def _repr_(self):
@@ -720,7 +721,7 @@ def _repr_(self):
720721

721722
def _simplicial_(self):
722723
"""
723-
Return the associated simplicial complex
724+
Return the associated simplicial complex.
724725
725726
All simplices of the filtered simplicial complex are
726727
included in the resulting simplicial complex.

0 commit comments

Comments
 (0)