From 4d9bcdfb33beeee5b63344f4b4b877929f935aed Mon Sep 17 00:00:00 2001 From: Periklis_ts Date: Thu, 13 Jun 2024 19:01:12 +0300 Subject: [PATCH] fix: Smiles parsing There was an error when the user was providing a list of a single string. Now it is fixed --- jaqpotpy/datasets/molecular_datasets.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/jaqpotpy/datasets/molecular_datasets.py b/jaqpotpy/datasets/molecular_datasets.py index f07aa1d6..1f7afc40 100644 --- a/jaqpotpy/datasets/molecular_datasets.py +++ b/jaqpotpy/datasets/molecular_datasets.py @@ -68,14 +68,17 @@ def x_cols_all(self) -> Iterable[str]: return self._x_cols_all @x_cols_all.setter - def x_colls_all(self, value): + def x_cols_all(self, value): self._x_cols_all = value def create(self): - if len(self.smiles_cols == 1): - self.smiles = self._df[self.smiles_cols] + if (isinstance(self.smiles_cols,list) and len(self.smiles_cols) == 1): + self.smiles = self._df[self.smiles_cols[0]] descriptors = self.featurizer.featurize_dataframe(self.smiles) + elif isinstance(self.smiles_cols,str): + self.smiles = self._df[self.smiles_cols] + descriptors = self.featurizer.featurize_dataframe(self.smiles) else: featurized_dfs = [self.featurizer.featurize_dataframe(self._df[[col]]) for col in self.smiles_cols] descriptors = pd.concat(featurized_dfs, axis=1) @@ -93,10 +96,10 @@ def create(self): self._df = pd.concat([self._x, self._y], axis = 1) - def __get_X__(self): + def __get_x__(self): return self.df[self._x].to_numpy() - def __get_Y__(self): + def __get_y__(self): return self.df[self._y].to_numpy() def __get__(self, instance, owner):