Skip to content

Commit

Permalink
Add changes from PR #26
Browse files Browse the repository at this point in the history
  • Loading branch information
kpzn768 committed Dec 16, 2024
1 parent cd30139 commit 42009b3
Show file tree
Hide file tree
Showing 7 changed files with 196 additions and 64 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ repos:
- id: check-added-large-files
- id: check-merge-conflict
- repo: https://github.com/psf/black
rev: 22.0.0
rev: 24.1.0
hooks:
- id: black
# We should add some linter to here at some point
236 changes: 182 additions & 54 deletions poetry.lock

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ packages = [
]

[tool.poetry.dependencies]
python = ">=3.9,<3.11"
python = ">=3.9,<3.13"
urllib3 = "^1.2.26"
pandas = "^1.0.0"
pandas = ">=1.0.0,<3.0.0"
xxhash = "^2.0.0"
rdchiral = "^1.1.0"
PyYAML = "^6.0.1"
Expand All @@ -30,6 +30,7 @@ cgrtools = "^4.1.35"
scipy = "^1.11.4"
pydantic = "^2.8.2"
apted = "^1.0.3"
dask = ">=2024.4.1"
onnxruntime = {version = "<1.17.0", optional=true}

[tool.poetry.group.dev.dependencies]
Expand Down
6 changes: 3 additions & 3 deletions rxnutils/pipeline/actions/dataframe_mod.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class DropColumns:
columns: list[str]

def __call__(self, data: pd.DataFrame) -> pd.DataFrame:
return data.drop(self.columns, 1)
return data.drop(self.columns, axis=1)

def __str__(self) -> str:
return f"{self.pretty_name} (drop columns in specified list, keeps the rest)"
Expand Down Expand Up @@ -100,7 +100,7 @@ def __call__(self, data: pd.DataFrame) -> pd.DataFrame:
for name in self.columns:
drop_columns.remove(name)

return data.drop(drop_columns, 1)
return data.drop(drop_columns, axis=1)

def __str__(self) -> str:
return f"{self.pretty_name} (keeps columns in specified list, drops the rest)"
Expand Down Expand Up @@ -187,7 +187,7 @@ def __call__(self, data: pd.DataFrame) -> pd.DataFrame:
value_vars=self.in_columns,
var_name=var_column_name,
value_name=self.out_column,
).drop(var_column_name, 1)
).drop(var_column_name, axis=1)

def __str__(self) -> str:
return f"{self.pretty_name} (stacks two columns into a single column)"
Expand Down
6 changes: 4 additions & 2 deletions rxnutils/pipeline/actions/reaction_mod.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,8 +262,10 @@ class IsotopeInfo:

def __call__(self, data: pd.DataFrame) -> pd.DataFrame:
isotop_info = data[self.in_column].str.extract(self.match_regex)
isotop_col = isotop_info.mass + isotop_info.symbol
rsmi_col = data[self.in_column].str.replace(self.match_regex, self.sub_regex)
isotop_col = isotop_info["mass"] + isotop_info["symbol"]
rsmi_col = data[self.in_column].str.replace(
self.match_regex, self.sub_regex, regex=True
)
return data.assign(**{self.isotope_column: isotop_col, self.out_column: rsmi_col})

def __str__(self) -> str:
Expand Down
2 changes: 1 addition & 1 deletion rxnutils/routes/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ def _assign_mapping(self, overwrite: bool = False, only_rxnmapper: bool = False)
df["mapped_smiles"] = df["RxnmapperRxnSmiles"]
else:
sel = df["NMC"] == "0.0"
df["mapped_smiles"].mask(sel, df["RxnmapperRxnSmiles"], inplace=True)
df.loc[sel, "mapped_smiles"] = df.loc[sel, "RxnmapperRxnSmiles"]
datamap = df.set_index("smiles").to_dict("index")
_copy_mapping_from_datamap(self.reaction_tree, datamap)

Expand Down
3 changes: 2 additions & 1 deletion rxnutils/routes/readers.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,8 @@ def reaction_dataframe2routes(subdata):
return route

metadata_columns = metadata_columns or []
return data.groupby(group_by).apply(reaction_dataframe2routes)
grouped = data.groupby(group_by)[data.columns.to_list()]
return grouped.apply(reaction_dataframe2routes)


def reactions2route(reactions: Sequence[str], metadata: Sequence[Dict[str, Any]] = None) -> SynthesisRoute:
Expand Down

0 comments on commit 42009b3

Please sign in to comment.