Skip to content

Commit

Permalink
WIP-Remove hashing from all classes
Browse files Browse the repository at this point in the history
  • Loading branch information
umesh-timalsina committed Apr 4, 2022
1 parent 0f5429e commit c7de431
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 61 deletions.
8 changes: 0 additions & 8 deletions gmso/abc/abstract_potential.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,14 +126,6 @@ def set_expression(self):
"""Set the functional form of the expression."""
raise NotImplementedError

def __eq__(self, other):
"""Compare two potentials for equivalence."""
return hash(self) == hash(other)

def __hash__(self):
"""Create a unique hash for the potential."""
return hash(tuple((self.name, self.potential_expression)))

def __setattr__(self, key: Any, value: Any) -> None:
"""Set attributes of the potential."""
if key == "expression":
Expand Down
13 changes: 0 additions & 13 deletions gmso/core/atom_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,19 +127,6 @@ def definition(self):
"""Return the SMARTS string of the atom_type."""
return self.__dict__.get("definition_")

def __hash__(self):
"""Return the hash of the atom_type."""
return hash(
tuple(
(
self.name,
unyt_to_hashable(self.mass),
unyt_to_hashable(self.charge),
self.potential_expression,
)
)
)

def __repr__(self):
"""Return a formatted representation of the atom type."""
desc = (
Expand Down
15 changes: 0 additions & 15 deletions gmso/core/element.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,21 +45,6 @@ def __repr__(self):
f"atomic number: {self.atomic_number}, mass: {self.mass.to('amu')}>"
)

def __eq__(self, other):
"""Return true if the element is equvalent to another element."""
return hash(self) == hash(other)

def __hash__(self):
"""Generate an unique hash of the element for comparison."""
return hash(
(
self.name,
self.symbol,
self.atomic_number,
unyt_to_hashable(self.mass),
)
)

class Config:
"""Pydantic configuration for element."""

Expand Down
25 changes: 0 additions & 25 deletions gmso/utils/expression.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,31 +171,6 @@ def set(self, expression=None, parameters=None, independent_variables=None):
if sympy.Symbol(key) not in self.expression.free_symbols:
self._parameters.pop(key)

def __hash__(self):
"""Return hash of the potential expression."""
if self._is_parametric:
return hash(
tuple(
(
self.expression,
tuple(self.independent_variables),
tuple(self.parameters.keys()),
tuple(
unyt_to_hashable(val)
for val in self.parameters.values()
),
)
)
)
else:
return hash(
tuple((self.expression, tuple(self.independent_variables)))
)

def __eq__(self, other):
"""Determine if two expressions are equivalent."""
return hash(self) == hash(other)

def __repr__(self):
"""Representation of the potential expression."""
descr = list(f"<PotentialExpression, ")
Expand Down

0 comments on commit c7de431

Please sign in to comment.