From c7de431d78c285464186babd48f6b8c338685b7e Mon Sep 17 00:00:00 2001 From: Umesh Timalsina Date: Mon, 4 Apr 2022 11:15:33 -0500 Subject: [PATCH] WIP-Remove hashing from all classes --- gmso/abc/abstract_potential.py | 8 -------- gmso/core/atom_type.py | 13 ------------- gmso/core/element.py | 15 --------------- gmso/utils/expression.py | 25 ------------------------- 4 files changed, 61 deletions(-) diff --git a/gmso/abc/abstract_potential.py b/gmso/abc/abstract_potential.py index e16d2a883..4ab1febee 100644 --- a/gmso/abc/abstract_potential.py +++ b/gmso/abc/abstract_potential.py @@ -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": diff --git a/gmso/core/atom_type.py b/gmso/core/atom_type.py index 0c20dd4e1..8074ce6a6 100644 --- a/gmso/core/atom_type.py +++ b/gmso/core/atom_type.py @@ -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 = ( diff --git a/gmso/core/element.py b/gmso/core/element.py index 12b097b56..ab957b0cf 100644 --- a/gmso/core/element.py +++ b/gmso/core/element.py @@ -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.""" diff --git a/gmso/utils/expression.py b/gmso/utils/expression.py index 629d07633..212da212c 100644 --- a/gmso/utils/expression.py +++ b/gmso/utils/expression.py @@ -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"