Skip to content

Commit

Permalink
revert type check change for now
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielYang59 committed Nov 28, 2024
1 parent d823c10 commit 06abd50
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/pymatgen/core/structure.py
Original file line number Diff line number Diff line change
Expand Up @@ -1097,22 +1097,23 @@ def __init__(

def __eq__(self, other: object) -> bool:
"""Define equality by comparing all three attributes: lattice, sites, properties."""
if not (hasattr(other, "lattice") and hasattr(other, "sites") and hasattr(other, "properties")):
needed_attrs = ("lattice", "sites", "properties")
if not all(hasattr(other, attr) for attr in needed_attrs):
return NotImplemented

# TODO (DanielYang59): fix below type
other = cast(Structure, other) # make mypy happy

if other is self:
return True

if isinstance(other, collections.abc.Sized) and len(self) != len(other):
if len(self) != len(other):
return False

if self.lattice != other.lattice:
return False
if self.properties != other.properties:
return False

if not isinstance(other, collections.abc.Container):
return False
return all(site in other for site in self)

def __hash__(self) -> int:
Expand Down

0 comments on commit 06abd50

Please sign in to comment.