elif (cf is not None) and (cf2 is not None) and (cf == cf2):
# both have cosmo_factor, and they match:
pass
should be:
elif (cf is not None) and (cf2 is not None) and ((cf == cf2) or (cf is None and cf2 is None)):
# both have cosmo_factor, and they match, or neither has cosmo_factor:
pass
In function
_return_without_cosmo_factor
this:should be: