Opened 7 years ago

Last modified 6 years ago

## #18251 new defect

# Equality comparison with 0 is not consistant — at Initial Version

Reported by: | tscrim | Owned by: | tscrim |
---|---|---|---|

Priority: | critical | Milestone: | sage-7.4 |

Component: | coercion | Keywords: | zero |

Cc: | nthiery, darij, nbruin, robertwb, chapoton, vdelecroix | Merged in: | |

Authors: | Reviewers: | ||

Report Upstream: | N/A | Work issues: | |

Branch: | Commit: | ||

Dependencies: | Stopgaps: |

### Description

Currently we have the following in Sage:

sage: C = CombinatorialFreeModule(QQ, ['a','b']) sage: C.zero() == ZZ(0) True sage: C.zero() == QQ(0) False sage: M.zero() (0, 0, 0, 0) sage: M.zero() == ZZ(0) True sage: M.zero() == QQ(0) False

What I've been doing has been implementing a custom `__eq__`

which checks explicitly for the other argument is 0 and then checking `self.is_zero`

. However I'm thinking we should have a general fix with this as a special case, but we could do it just for these element classes.

Additionally this works when there a coercion from the base ring. I guess more generally do we want equality checking for when there is a conversion to the base ring? Thoughts?

**Note:**See TracTickets for help on using tickets.