Skip to content

Commit

Permalink
Fix potential features misalignment
Browse files Browse the repository at this point in the history
  • Loading branch information
swansonk14 committed Aug 20, 2020
1 parent 15aaef2 commit 76e9b68
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions chemprop/data/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,22 +173,25 @@ def get_data(path: str,
ignore_columns = set([smiles_column] + ([] if ignore_columns is None else ignore_columns))
target_columns = [column for column in columns if column not in ignore_columns]

all_smiles, all_targets, all_rows = [], [], []
for row in tqdm(reader):
all_smiles, all_targets, all_rows, all_features = [], [], [], []
for i, row in tqdm(enumerate(reader)):
smiles = row[smiles_column]

if smiles in skip_smiles:
continue

targets = [float(row[column]) if row[column] != '' else None for column in target_columns]

if skip_none_targets and all(x is None for x in targets):
# Check whether all targets are None and skip if so
if skip_none_targets and all(x is None for x in targets):
continue

all_smiles.append(smiles)
all_targets.append(targets)

if features_data is not None:
all_features.append(features_data[i])

if store_row:
all_rows.append(row)

Expand All @@ -201,7 +204,7 @@ def get_data(path: str,
targets=targets,
row=all_rows[i] if store_row else None,
features_generator=features_generator,
features=features_data[i] if features_data is not None else None
features=all_features[i] if features_data is not None else None
) for i, (smiles, targets) in tqdm(enumerate(zip(all_smiles, all_targets)),
total=len(all_smiles))
])
Expand Down

0 comments on commit 76e9b68

Please sign in to comment.