def __hash__(self): return hash( tuple((self.name, unyt_to_hashable(self.mass), unyt_to_hashable(self.charge), self.expression, tuple(self.independent_variables), tuple(self.parameters.keys()), tuple( unyt_to_hashable(val) for val in self.parameters.values()))))
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 __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), ))
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 test_unyt_to_hashable(): hash(unyt_to_hashable(None)) hash(unyt_to_hashable(1 * u.nm)) hash(unyt_to_hashable([4, 4] * u.nm)) assert hash(unyt_to_hashable(1 * u.nm)) == hash(unyt_to_hashable(10 * u.angstrom)) assert hash(unyt_to_hashable(1 * u.kg)) == hash(unyt_to_hashable(1000 * u.g)) assert hash(unyt_to_hashable(1 * u.nm)) != hash(unyt_to_hashable(1.01 * u.nm)) assert hash(unyt_to_hashable(1 * u.nm)) != hash(unyt_to_hashable(1.01 * u.second)) assert hash(unyt_to_hashable(1 * u.nm)) != hash(unyt_to_hashable([1, 1] * u.nm))
def __hash__(self): return hash((self.name, self.symbol, self.atomic_number, unyt_to_hashable(self.mass)))
def __hash__(self): return hash( tuple((self.name, unyt_to_hashable(self.mass), unyt_to_hashable(self.charge), self.potential_expression)))