diff --git a/doranet/filters.py b/doranet/filters.py index 6c32071..92ed369 100644 --- a/doranet/filters.py +++ b/doranet/filters.py @@ -132,9 +132,7 @@ def __call__( op: typing.Optional[interfaces.DataPacket[interfaces.OpDatBase]], arg_num: typing.Optional[int], ) -> bool: - if mol.meta is None or self.key not in mol.meta: - return False - return True + return not (mol.meta is None or self.key not in mol.meta) @property def meta_required(self) -> interfaces.MetaKeyPacket: @@ -225,9 +223,7 @@ class CoreactantFilter(interfaces.RecipeFilter): coreactants: collections.abc.Container[interfaces.MolIndex] def __call__(self, recipe: interfaces.RecipeExplicit) -> bool: - if all(mol.i in self.coreactants for mol in recipe.reactants): - return False - return True + return not all(mol.i in self.coreactants for mol in recipe.reactants) @property def meta_required(self) -> interfaces.MetaKeyPacket: @@ -243,14 +239,12 @@ class GenerationFilter(metadata.ReactionFilterBase): gen_key: collections.abc.Hashable def __call__(self, recipe: interfaces.ReactionExplicit) -> bool: - if all( + return all( mol.meta is not None and self.gen_key in mol.meta and mol.meta[self.gen_key] + 1 < self.max_gens for mol in recipe.reactants - ): - return True - return False + ) @property def meta_required(self) -> interfaces.MetaKeyPacket: @@ -291,9 +285,7 @@ def __call__(self, recipe: interfaces.ReactionExplicit): def ReplaceNewValue( key: collections.abc.Hashable, old_value: typing.Any, new_value: typing.Any ) -> bool: - if old_value != new_value: - return True - return False + return old_value != new_value class ReplaceBlacklist: diff --git a/doranet/interfaces.py b/doranet/interfaces.py index 406977b..ee83ff9 100644 --- a/doranet/interfaces.py +++ b/doranet/interfaces.py @@ -1001,13 +1001,11 @@ def __eq__(self, other: object) -> bool: If other is a Recipe, return equality of attributes between it and self. If other is not a Recipe, return False. """ - if ( + return ( isinstance(other, Recipe) and self.operator == other.operator and self.reactants == other.reactants - ): - return True - return False + ) def __lt__(self, other: "Recipe") -> bool: """ diff --git a/doranet/modules/enzymatic/generate_network.py b/doranet/modules/enzymatic/generate_network.py index 125d47e..9127b82 100644 --- a/doranet/modules/enzymatic/generate_network.py +++ b/doranet/modules/enzymatic/generate_network.py @@ -352,9 +352,7 @@ def __call__(self, recipe: interfaces.ReactionExplicit) -> bool: return True if dH == float("nan"): return False - if dH < self.max_dH: - return True - return False + return dH < self.max_dH @property def meta_required(self) -> interfaces.MetaKeyPacket: diff --git a/doranet/modules/post_processing/post_processing.py b/doranet/modules/post_processing/post_processing.py index 76e0b88..ceaa240 100644 --- a/doranet/modules/post_processing/post_processing.py +++ b/doranet/modules/post_processing/post_processing.py @@ -1154,9 +1154,7 @@ def __call__(self, recipe: interfaces.ReactionExplicit) -> bool: return True if dH == float("nan"): return False - if dH < self.max_dH: - return True - return False + return dH < self.max_dH @property def meta_required(self) -> interfaces.MetaKeyPacket: @@ -2082,7 +2080,7 @@ def SMILES_rm_keku( weight.append(weights["salt_score"]) weight.append(weights["in_reaxys"]) weight.append(weights["coolness"]) - # + final_score = list() for i in range(len(data)): @@ -2424,7 +2422,7 @@ def SMILES_rm_keku( if "2-step" in name_list[idx] or "&" in name_list[idx]: dH_list[idx] = dH_list[idx] + " ×2" - for idx, _i in enumerate(name_list): # add dH to name + for idx in range(len(name_list)): # add dH to name if name_list[idx].replace("\n", " ") in salt_name_set: name_list[idx] = name_list[idx] + "(salt)" name_list[idx] = name_list[idx] + "\n" + dH_list[idx] diff --git a/doranet/modules/synthetic/generate_network.py b/doranet/modules/synthetic/generate_network.py index 94e6f53..12918ae 100644 --- a/doranet/modules/synthetic/generate_network.py +++ b/doranet/modules/synthetic/generate_network.py @@ -105,9 +105,7 @@ def __call__(self, recipe: interfaces.ReactionExplicit) -> bool: return True if dH == float("nan"): return False - if dH < self.max_dH: - return True - return False + return dH < self.max_dH @property def meta_required(self) -> interfaces.MetaKeyPacket: @@ -298,9 +296,7 @@ def __call__(self, recipe: interfaces.RecipeExplicit) -> bool: for mol in recipe.reactants: if mol.i not in self.coreactants: reactant_set.add(mol.i) - if len(set(reactant_set)) != 1: - return False - return True + return len(set(reactant_set)) == 1 @property def meta_required(self) -> interfaces.MetaKeyPacket: diff --git a/doranet/strategies.py b/doranet/strategies.py index 8586f87..929eb58 100644 --- a/doranet/strategies.py +++ b/doranet/strategies.py @@ -797,13 +797,11 @@ def __lt__(self, other: "RecipePriorityItem") -> bool: return self.rank < other.rank def __eq__(self, other: object) -> bool: - if ( + return ( isinstance(other, RecipePriorityItem) and self.rank == other.rank and self.recipe == other.recipe - ): - return True - return False + ) def execute_recipe_ranking( @@ -1121,7 +1119,7 @@ def expand( mc_update = metadata.MetaUpdateResolver({}, {}, {}) if heap_size is not None and beam_size is not None: - ValueError( + raise ValueError( f"""Heap size ({heap_size}) must be greater than beam size ({beam_size})""" ) diff --git a/pyproject.toml b/pyproject.toml index 8c5e0f0..b255606 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "hatchling.build" [project] name = 'doranet' -version = '0.5.3a5' +version = '0.5.3a7' authors = [ { name='William Sprague', email='wsprague@u.northwestern.edu' }, { name='Quan Zhang', email='quanzhang@northwestern.edu' },