Skip to content

Commit

Permalink
Merge pull request #15 from wsprague-nu/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
wsprague-nu authored Jul 1, 2024
2 parents 06ecf31 + f333cb0 commit 4fc31b9
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 37 deletions.
18 changes: 5 additions & 13 deletions doranet/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand All @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
6 changes: 2 additions & 4 deletions doranet/interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
"""
Expand Down
4 changes: 1 addition & 3 deletions doranet/modules/enzymatic/generate_network.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
8 changes: 3 additions & 5 deletions doranet/modules/post_processing/post_processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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)):
Expand Down Expand Up @@ -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]
Expand Down
8 changes: 2 additions & 6 deletions doranet/modules/synthetic/generate_network.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
8 changes: 3 additions & 5 deletions doranet/strategies.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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})"""
)
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "hatchling.build"

[project]
name = 'doranet'
version = '0.5.3a5'
version = '0.5.3a7'
authors = [
{ name='William Sprague', email='[email protected]' },
{ name='Quan Zhang', email='[email protected]' },
Expand Down

0 comments on commit 4fc31b9

Please sign in to comment.