Skip to content

Commit

Permalink
docs, plus shortcutting for memory equality
Browse files Browse the repository at this point in the history
  • Loading branch information
peterdsharpe committed Mar 30, 2024
1 parent 35c11d0 commit ab53896
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions aerosandbox/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,22 @@ def __eq__(self, other):
Returns:
bool: True if the objects are equal, False otherwise.
"""
if type(self) != type(other):
if self is other: # If they point to the same object in memory, they're equal
return True

if type(self) != type(other): # If they are of different types, they cannot be equal
return False
if set(self.__dict__.keys()) != set(other.__dict__.keys()):

if set(self.__dict__.keys()) != set(
other.__dict__.keys()): # If they have differing dict keys, don't bother checking values
return False

for key in self.__dict__.keys():
for key in self.__dict__.keys(): # Check equality of all values
if np.all(self.__dict__[key] == other.__dict__[key]):
continue
else:
return False

return True

def save(self,
Expand Down

0 comments on commit ab53896

Please sign in to comment.