Ticket #13220: trac_13220-chain-complex.patch

File trac_13220-chain-complex.patch, 2.9 KB (added by jhpalmieri, 11 years ago)
  • sage/homology/chain_complex_morphism.py

    # HG changeset patch
    # User J. H. Palmieri <palmieri@math.washington.edu>
    # Date 1341932892 18000
    # Node ID 3c16df5da2cb65708bbabf1f9eec35a77d3efaaa
    # Parent  7a2a36b9da0fc4bfc82fbd11ca7d48f741f74bf7
    Fix a bug in morphisms of chain complexes.
    
    diff --git a/sage/homology/chain_complex_morphism.py b/sage/homology/chain_complex_morphism.py
    a b class ChainComplexMorphism(SageObject): 
    106106            [0 0 0]
    107107            [0 0 0]}
    108108
     109        Check that the bug in :trac:`13220` has been fixed::
     110
     111            sage: X = simplicial_complexes.Simplex(1)
     112            sage: Y = simplicial_complexes.Simplex(0)
     113            sage: g = Hom(X,Y)({0:0, 1:0})
     114            sage: g.associated_chain_complex_morphism()
     115            Chain complex morphism from Chain complex with at most 2 nonzero terms over Integer Ring to Chain complex with at most 1 nonzero terms over Integer Ring
    109116        """
    110117        if C._grading_group != ZZ:
    111118            raise NotImplementedError, "Chain complex morphisms are not implemented over gradings other than ZZ."
    class ChainComplexMorphism(SageObject): 
    132139                    if not matrices[i]*C.differential()[i+1]==D.differential()[i+1]*matrices[i+1]:
    133140                        raise ValueError, "Matrices must define a chain complex morphism."
    134141                elif (i+1) in C.differential().keys():
    135                     if not matrices[i]*C.differential()[i+1].is_zero():
     142                    if not (matrices[i]*C.differential()[i+1]).is_zero():
    136143                        raise ValueError, "Matrices must define a chain complex morphism."
    137144                elif (i+1) in D.differential().keys():
    138                     if not D.differential()[i+1]*matrices[i+1].is_zero():
     145                    if not (D.differential()[i+1]*matrices[i+1]).is_zero():
    139146                        raise ValueError, "Matrices must define a chain complex morphism."
    140147            else:
    141148                if i in C.differential().keys() and i in D.differential().keys():
    142149                    if not matrices[i+1]*C.differential()[i]==D.differential()[i]*matrices[i]:
    143150                        raise ValueError, "Matrices must define a chain complex morphism."
    144151                elif i in C.differential().keys():
    145                     if not matrices[i+1]*C.differential()[i].is_zero():
     152                    if not (matrices[i+1]*C.differential()[i]).is_zero():
    146153                        raise ValueError, "Matrices must define a chain complex morphism."
    147154                elif i in D.differential().keys():
    148                     if not D.differential()[i]*matrices[i].is_zero():
     155                    if not (D.differential()[i]*matrices[i]).is_zero():
    149156                        raise ValueError, "Matrices must define a chain complex morphism."
    150157        self._matrix_dictionary = matrices
    151158        self._domain = C