# 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): 
106  106  [0 0 0] 
107  107  [0 0 0]} 
108  108  
 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 
109  116  """ 
110  117  if C._grading_group != ZZ: 
111  118  raise NotImplementedError, "Chain complex morphisms are not implemented over gradings other than ZZ." 
… 
… 
class ChainComplexMorphism(SageObject): 
132  139  if not matrices[i]*C.differential()[i+1]==D.differential()[i+1]*matrices[i+1]: 
133  140  raise ValueError, "Matrices must define a chain complex morphism." 
134  141  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(): 
136  143  raise ValueError, "Matrices must define a chain complex morphism." 
137  144  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(): 
139  146  raise ValueError, "Matrices must define a chain complex morphism." 
140  147  else: 
141  148  if i in C.differential().keys() and i in D.differential().keys(): 
142  149  if not matrices[i+1]*C.differential()[i]==D.differential()[i]*matrices[i]: 
143  150  raise ValueError, "Matrices must define a chain complex morphism." 
144  151  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(): 
146  153  raise ValueError, "Matrices must define a chain complex morphism." 
147  154  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(): 
149  156  raise ValueError, "Matrices must define a chain complex morphism." 
150  157  self._matrix_dictionary = matrices 
151  158  self._domain = C 