Skip to content

Commit

Permalink
Changed attribute name and fixed bigraded_betti_number()
Browse files Browse the repository at this point in the history
  • Loading branch information
OP5642 committed Apr 16, 2023
1 parent 6efeca8 commit 157384a
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions src/sage/topology/simplicial_complex.py
Original file line number Diff line number Diff line change
Expand Up @@ -1045,7 +1045,7 @@ def __init__(self,
if not is_mutable or is_immutable:
self.set_immutable()
self._bbn = C._bbn
self.__bbn_called_rings = C.__bbn_called_rings
self._bbn_all_computed = C._bbn_all_computed
return

gen_dict = {}
Expand Down Expand Up @@ -1132,9 +1132,9 @@ def __init__(self,
# bigraded Betti numbers, indexed by tuples (-i, 2j).
# For use in the bigraded_betti_numbers method.
self._bbn = {}
# self.__bbn_called_rings: a set of base rings for which we called
# self._bbn_all_computed: a set of base rings for which we called
# bigraded_betti_numbers(base_ring=base_ring)
self.__bbn_called_rings = set()
self._bbn_all_computed = set()

def __hash__(self):
"""
Expand Down Expand Up @@ -2670,7 +2670,7 @@ def add_face(self, face):
self._complex = {}
self.__contractible = None
self._bbn = {}
self.__bbn_called_rings = set()
self._bbn_all_computed = set()

def remove_face(self, face, check=False):
"""
Expand Down Expand Up @@ -2796,7 +2796,7 @@ def remove_face(self, face, check=False):
self.__contractible = None
self.__enlarged = {}
self._bbn = {}
self.__bbn_called_rings = set()
self._bbn_all_computed = set()

def remove_faces(self, faces, check=False):
"""
Expand Down Expand Up @@ -4834,7 +4834,7 @@ def bigraded_betti_numbers(self, base_ring=ZZ):
sage: Y.bigraded_betti_numbers(base_ring=QQ)
{(0, 0): 1, (-1, 4): 3, (-2, 6): 1, (-2, 8): 2, (-3, 10): 1}
"""
if base_ring in self.__bbn_called_rings:
if base_ring in self._bbn_all_computed:
return self._bbn[base_ring]

from sage.homology.homology_group import HomologyGroup
Expand All @@ -4856,10 +4856,8 @@ def bigraded_betti_numbers(self, base_ring=ZZ):
B[ind] = ZZ.zero()
B[ind] += len(H[j-k-1].gens())

# We update the dictionary, because some of the
# single values may already be stored in self._bbn[base_ring]
self._bbn[base_ring] = B
self.__bbn_called_rings.add(base_ring)
self._bbn_all_computed.add(base_ring)

return B

Expand Down Expand Up @@ -4893,7 +4891,10 @@ def bigraded_betti_number(self, a, b, base_ring=ZZ):
if a == 0 and b == 0:
return ZZ.one()
if base_ring in self._bbn:
return self._bbn[base_ring].get((a,b), ZZ.zero())
if base_ring in self._bbn_all_computed:
return self._bbn[base_ring].get((a,b), ZZ.zero())
elif (a, b) in self._bbn[base_ring]:
return self._bbn[base_ring][a, b]

from sage.homology.homology_group import HomologyGroup

Expand Down

0 comments on commit 157384a

Please sign in to comment.