diff --git a/python_wrapper/setup.py b/python_wrapper/setup.py index 21de3ab89..563bd8833 100644 --- a/python_wrapper/setup.py +++ b/python_wrapper/setup.py @@ -2,7 +2,7 @@ setup( name='twa', - version='0.0.7', + version='0.0.8-15-SNAPSHOT', author='Jiaru Bai; Daniel Nurkowski', author_email='jb2197@cam.ac.uk; danieln@cmclinnovations.com', license='MIT', diff --git a/python_wrapper/twa/__init__.py b/python_wrapper/twa/__init__.py index 549b8a8b0..237c52d13 100644 --- a/python_wrapper/twa/__init__.py +++ b/python_wrapper/twa/__init__.py @@ -1,3 +1,3 @@ from twa.JPSGateway import JPSGateway -__version__ = "0.0.7" +__version__ = "0.0.8-15-SNAPSHOT" diff --git a/python_wrapper/twa/data_model/base_ontology.py b/python_wrapper/twa/data_model/base_ontology.py index d80e5b486..b2897fc96 100644 --- a/python_wrapper/twa/data_model/base_ontology.py +++ b/python_wrapper/twa/data_model/base_ontology.py @@ -1529,11 +1529,18 @@ def _exclude_keys_for_compare_(self, *keys_to_exclude): return set(tuple(list_keys_to_exclude)) def __eq__(self, other: Any) -> bool: - return self.__hash__() == other.__hash__() + try: + return self.instance_iri == other.instance_iri + except TypeError: + # if other doesn't have instance_iri, then it's not comparable + return False + __hash_cache__ = None def __hash__(self): # using instance_iri for hash so that iri and object itself are treated the same in set operations - return self.instance_iri.__hash__() + if self.__hash_cache__ is None: + self.__hash_cache__ = self.instance_iri.__hash__() + return self.__hash_cache__ # TODO [future] do we want to provide the method to compare if the content of two instances are the same? # a use case would be to compare if the chemicals in the two bottles are the same concentration # return self._make_hash_sha256_(self.dict(exclude=self._exclude_keys_for_compare_()))