From dd49f1e278308a61cfffeaf2480f5a2e42b72a9f Mon Sep 17 00:00:00 2001 From: JacksonBurns Date: Thu, 3 Feb 2022 23:47:19 -0500 Subject: [PATCH] `getattr` faster than `hasattr` --- AIMSim/ops/descriptor.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/AIMSim/ops/descriptor.py b/AIMSim/ops/descriptor.py index 974cbcf4..4b382c53 100644 --- a/AIMSim/ops/descriptor.py +++ b/AIMSim/ops/descriptor.py @@ -81,9 +81,7 @@ def to_rdkit(self): return self.rdkit_ def check_init(self): - if hasattr(self, "numpy_") or hasattr(self, "rdkit_"): - return True - return False + return getattr(self, "numpy_", None) is not None or getattr(self, "rdkit_", None) is not None def _set_morgan_fingerprint(self, molecule_graph, radius, n_bits, **kwargs): """Set the descriptor to a morgan fingerprint.