Skip to content

Commit

Permalink
Add hashed test again and remove outdated tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
niekdejonge committed Oct 25, 2024
1 parent 7f02d8c commit d3b3e52
Showing 1 changed file with 11 additions and 34 deletions.
45 changes: 11 additions & 34 deletions tests/test_ms2deepscore.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from pathlib import Path
import numpy as np
import pytest

from ms2deepscore import MS2DeepScore
from ms2deepscore.models import load_model
from tests.create_test_spectra import pesticides_test_spectra
Expand Down Expand Up @@ -63,37 +65,12 @@ def test_MS2DeepScore_score_matrix_symmetric():
assert np.allclose(expected_scores, scores, atol=1e-6), "Expected different scores."


# def test_MS2DeepScore_score_matrix_symmetric_wrong_use():
# """Test if *.matrix* method gives correct exception."""
# spectrums, _, similarity_measure = get_test_ms2_deep_score_instance()
# expected_msg = "Expected references to be equal to queries for is_symmetric=True"
# with pytest.raises(AssertionError) as msg:
# _ = similarity_measure.matrix(spectrums[:4],
# [spectrums[i] for i in [1,2,3,0]],
# is_symmetric=True)
# assert expected_msg in str(msg), "Expected different exception message"
# assert not similarity_measure.multi_inputs

# def get_test_ms2_deep_score_instance_additional_inputs():
# """Load data and models for MS2DeepScore unit tests."""
# spectrums = load_processed_spectrums()
#
# # Load pretrained model
# model_file = TEST_RESOURCES_PATH / "testmodel_additional_input.hdf5"
# model = load_model(model_file)
#
# similarity_measure = MS2DeepScore(model)
# return spectrums, model, similarity_measure

# def test_MS2DeepScore_score_additional_input_feature():
# """Test vector creation."""
# spectrums, model, similarity_measure = get_test_ms2_deep_score_instance_additional_inputs()
#
# binned_spectrum0 = model.spectrum_binner.transform([spectrums[0]])[0]
# inputs = similarity_measure._create_input_vector(binned_spectrum0)
# assert isinstance(inputs, list), "Expected inputs to be list"
# assert inputs[0].shape == (1, 543), "Expected different vector shape"
# assert inputs[1].shape == (1, model.nr_of_additional_inputs), "Expected different shape for additional_input"
# assert isinstance(inputs[0], np.ndarray), "Expected vector to be numpy array"
# assert inputs[0][0, 92] == 0.0, "Expected different entries"
# assert similarity_measure.multi_inputs
def test_MS2DeepScore_score_matrix_symmetric_wrong_use():
"""Test if *.matrix* method gives correct exception."""
spectrums, _, similarity_measure = get_test_ms2deepscore_instance()
expected_msg = "Expected references to be equal to queries for is_symmetric=True"
with pytest.raises(AssertionError) as msg:
_ = similarity_measure.matrix(spectrums[:4],
[spectrums[i] for i in [1,2,3,0]],
is_symmetric=True)
assert expected_msg in str(msg), "Expected different exception message"

0 comments on commit d3b3e52

Please sign in to comment.