90
90
from sage .rings .infinity import infinity
91
91
from sage .misc .cachefunc import cached_method
92
92
93
+
93
94
class FilteredSimplicialComplex (SageObject ):
94
95
r"""
95
96
Define a filtered complex.
@@ -321,7 +322,7 @@ def filtration(self, s, filtration_value=None):
321
322
322
323
If ``filtration_value`` is set, this function inserts the
323
324
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.
325
326
326
327
EXAMPLES::
327
328
@@ -338,7 +339,7 @@ def filtration(self, s, filtration_value=None):
338
339
else :
339
340
self ._insert (s , filtration_value )
340
341
341
- def prune (self ,threshold ):
342
+ def prune (self , threshold ):
342
343
r"""
343
344
Return a copy of the filtered complex, where simplices above
344
345
the threshold value have been removed.
@@ -367,7 +368,7 @@ def prune(self,threshold):
367
368
368
369
return result_complex
369
370
370
- @cached_method (key = lambda self ,f , s , v : (f ,s ))
371
+ @cached_method (key = lambda self , f , s , v : (f , s ))
371
372
def _persistent_homology (self , field = 2 , strict = True , verbose = False ):
372
373
"""
373
374
Compute the homology intervals of the complex.
@@ -445,7 +446,7 @@ def key(s):
445
446
# Initialize data structures for the algo
446
447
self ._marked = [False ] * n
447
448
self ._T = [None ] * n
448
- intervals = [[] for i in range (self ._dimension + 1 )]
449
+ intervals = [[] for i in range (self ._dimension + 1 )]
449
450
self .pairs = []
450
451
451
452
self ._strict = strict
@@ -491,7 +492,7 @@ def _add_interval(self, s, t, intervals):
491
492
Add a new interval (i.e. homology element).
492
493
493
494
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
495
496
death may be ``None``, in which case the interval is infinite.
496
497
497
498
INPUT:
@@ -544,7 +545,7 @@ def _remove_pivot_rows(self, s, simplices):
544
545
545
546
This method implements the subroutine of the same name
546
547
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.
548
549
549
550
TESTS::
550
551
@@ -565,11 +566,11 @@ def _remove_pivot_rows(self, s, simplices):
565
566
return d
566
567
567
568
# Initialize the boundary chain
568
- for ( i , f ) in enumerate (s .faces ()):
569
+ for i , f in enumerate (s .faces ()):
569
570
d += (- 1 )** i * self ._chaingroup (f )
570
571
571
572
# Remove all unmarked elements
572
- for ( s , x_s ) in d :
573
+ for s , x_s in d :
573
574
j = self ._index_of_simplex [s ]
574
575
if not self ._marked [j ]:
575
576
d = d - x_s * self ._chaingroup (s )
@@ -586,7 +587,7 @@ def _remove_pivot_rows(self, s, simplices):
586
587
587
588
c = self ._T [max_index ][1 ]
588
589
q = c [t ]
589
- d = d - ((q ** (- 1 ))* c )
590
+ d = d - ((q ** (- 1 )) * c )
590
591
591
592
return d
592
593
@@ -595,8 +596,8 @@ def _max_index(self, d):
595
596
Return the maximal index of all simplices with nonzero
596
597
coefficient in ``d``.
597
598
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
600
601
outside of those methods.
601
602
602
603
TESTS::
@@ -611,7 +612,7 @@ def _max_index(self, d):
611
612
6
612
613
"""
613
614
currmax = - 1
614
- for ( s , x_s ) in d :
615
+ for s , x_s in d :
615
616
j = self ._index_of_simplex [s ]
616
617
if j > currmax :
617
618
currmax = j
@@ -664,7 +665,7 @@ def betti_number(self, k, a, b, field=2, strict=True, verbose=None):
664
665
persistent homology computation; the default is the verbosity
665
666
of ``self``
666
667
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
668
669
homology elements which are alive throughout the whole
669
670
duration ``[a, a+b]``.
670
671
@@ -686,7 +687,7 @@ def betti_number(self, k, a, b, field=2, strict=True, verbose=None):
686
687
if verbose is None :
687
688
verbose = self ._verbose
688
689
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 ]
690
691
if (i <= a and a + b < j ) and a >= 0 ))
691
692
692
693
def _repr_ (self ):
@@ -720,7 +721,7 @@ def _repr_(self):
720
721
721
722
def _simplicial_ (self ):
722
723
"""
723
- Return the associated simplicial complex
724
+ Return the associated simplicial complex.
724
725
725
726
All simplices of the filtered simplicial complex are
726
727
included in the resulting simplicial complex.
0 commit comments