-
Notifications
You must be signed in to change notification settings - Fork 989
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make EqualsTester notice incorrect delegation (#3809)
This extends EqualsTester to notice when someone incorrectly does not return NotImplemented in `__eq__` for objects of an unrecognized type. Doing this can cause commutativity to fail when implementing other objects that should be equal to this object. (It was worse in python 2, where depending on whether one inherited from object or not could cause this). This also fixes places where Cirq code was doing this incorrectly. Fixes #877 One final note is that the `eigen_gate_test` was changed because apparently Sympy does this incorrectly ``` >>> import sympy >>> s = sympy.Symbol("a") >>> class MyClass: ... def __eq__(self, other): ... return True ... >>> s.__eq__(MyClass()) False ```
- Loading branch information
Showing
7 changed files
with
125 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters