Skip to content

Commit

Permalink
Checked demos and added some extra tests for descriptor and sanitizer
Browse files Browse the repository at this point in the history
  • Loading branch information
Esben Bjerrm committed Oct 17, 2022
1 parent 0b0518f commit 59bed76
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
5 changes: 4 additions & 1 deletion tests/test_desctransformer.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,10 @@ def test_descriptor_transformer_transform(mols_list, default_descriptor_transfor
features = default_descriptor_transformer.transform(mols)
assert(len(features) == len(mols))
assert(len(features[0]) == len(Descriptors._descList))


def test_descriptor_transformer_wrong_descriptors():
with pytest.raises(AssertionError):
Desc2DTransformer(desc_list=['Color', 'Icecream content', 'ChokolateDarkness', 'Content42', 'MolWt'])



Expand Down
9 changes: 9 additions & 0 deletions tests/test_sanitizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,15 @@ def test_checksmilessanitation(smiles_list, invalid_smiles_list, sanitizer):
assert all([ a == b for a, b in zip(smiles_list, smiles_list_sanitized)])
assert errors[0] == sanitizer.errors.SMILES[0]

def test_checksmilessanitation_x_and_y(smiles_list, invalid_smiles_list, sanitizer):
smiles_list_sanitized, y_sanitized, errors, y_errors = sanitizer.sanitize(smiles_list, list(range(len(smiles_list))))
assert len(invalid_smiles_list) > len(smiles_list_sanitized)
assert all([ a == b for a, b in zip(smiles_list, smiles_list_sanitized)])
assert errors[0] == sanitizer.errors.SMILES[0]
#Test that y is correctly split into y_error and the rest
assert all([ a == b for a, b in zip(y_sanitized, list(range(len(smiles_list) -1 )))])
assert y_errors[0] == len(smiles_list)-1 #Last smiles is invalid

def test_checksmilessanitation_np(smiles_list, invalid_smiles_list, sanitizer):
smiles_list_sanitized, errors = sanitizer.sanitize(np.array(invalid_smiles_list))
assert len(invalid_smiles_list) > len(smiles_list_sanitized)
Expand Down

0 comments on commit 59bed76

Please sign in to comment.