Skip to content

Commit

Permalink
Update spectralprocessing.py function tests so that spectra are panda…
Browse files Browse the repository at this point in the history
…s series and not lists
  • Loading branch information
bkieft-usa committed Jul 23, 2024
1 parent 33629fc commit 3ce2546
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions tests/unit/test_spectralprocessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,63 +11,63 @@

def test_calc_data_to_ref_frag_ratio01():
num_matches = 5
spectrum = pd.Series([[1.1, 1.2, 1.3, 1.4, 1.5], [10, 100, 1000, 100, 10]])
spectrum = pd.Series([pd.Series([1.1, 1.2, 1.3, 1.4, 1.5]), pd.Series([10, 100, 1000, 100, 10])])
row = pd.Series({'num_matches': num_matches, 'spectrum': spectrum})
out = sp.calc_data_to_ref_frag_ratio(row)
assert out == 1.0

def test_calc_data_to_ref_frag_ratio02():
num_matches = 1
spectrum = pd.Series([[1.1, 1.2, 1.3, 1.4, 1.5], [10, 100, 1000, 100, 10]])
spectrum = pd.Series([pd.Series([1.1, 1.2, 1.3, 1.4, 1.5]), pd.Series([10, 100, 1000, 100, 10])])
row = pd.Series({'num_matches': num_matches, 'spectrum': spectrum})
out = sp.calc_data_to_ref_frag_ratio(row)
assert out == 0.2

def test_calc_data_to_ref_frag_ratio03():
num_matches = 0
spectrum = pd.Series([[1.1, 1.2, 1.3, 1.4, 1.5], [10, 100, 1000, 100, 10]])
spectrum = pd.Series([pd.Series([1.1, 1.2, 1.3, 1.4, 1.5]), pd.Series([10, 100, 1000, 100, 10])])
row = pd.Series({'num_matches': num_matches, 'spectrum': spectrum})
out = sp.calc_data_to_ref_frag_ratio(row)
assert out == 0.0

def test_calc_data_to_ref_frag_ratio04():
num_matches = 0
spectrum = pd.Series([[],[]])
spectrum = pd.Series([pd.Series([]),pd.Series([])])
row = pd.Series({'num_matches': num_matches, 'spectrum': spectrum})
out = sp.calc_data_to_ref_frag_ratio(row)
assert out == 0.0

def test_calc_jaccard_of_spectra01():
query_spectrum = pd.Series([[1.1, 1.2, 1.3, 1.4, 1.5], [10, 100, 1000, 100, 10]])
spectrum = pd.Series([[1.1, 1.2, 1.3, 1.4, 1.5], [10, 100, 1000, 100, 10]])
query_spectrum = pd.Series([pd.Series([1.1, 1.2, 1.3, 1.4, 1.5]), pd.Series([10, 100, 1000, 100, 10])])
spectrum = pd.Series([pd.Series([1.1, 1.2, 1.3, 1.4, 1.5]), pd.Series([10, 100, 1000, 100, 10])])
row = pd.Series({'query_spectrum': query_spectrum, 'spectrum': spectrum})
out = sp.calc_jaccard_of_spectra(row)
assert out == 1.0

def test_calc_jaccard_of_spectra02():
query_spectrum = pd.Series([[1.1], [10]])
spectrum = pd.Series([[1.1, 1.2, 1.3, 1.4, 1.5], [10, 100, 1000, 100, 10]])
query_spectrum = pd.Series([pd.Series([1.1]), pd.Series([10])])
spectrum = pd.Series([pd.Series([1.1, 1.2, 1.3, 1.4, 1.5]), pd.Series([10, 100, 1000, 100, 10])])
row = pd.Series({'query_spectrum': query_spectrum, 'spectrum': spectrum})
out = sp.calc_jaccard_of_spectra(row)
assert out == 0.2

def test_calc_jaccard_of_spectra03():
query_spectrum = pd.Series([[1.1, 1.3, 1.7, 1.9], [10, 100, 1000, 100, 10]])
spectrum = pd.Series([[1.1, 1.2, 1.3, 1.4, 1.5], [10, 100, 1000, 100, 10]])
query_spectrum = pd.Series([pd.Series([1.1, 1.3, 1.7, 1.9, 2.1]), pd.Series([10, 100, 1000, 100, 10])])
spectrum = pd.Series([pd.Series([1.1, 1.2, 1.3, 1.4, 1.5]), pd.Series([10, 100, 1000, 100, 10])])
row = pd.Series({'query_spectrum': query_spectrum, 'spectrum': spectrum})
out = sp.calc_jaccard_of_spectra(row)
assert out == 0.2857
assert out == 0.25

def test_calc_jaccard_of_spectra04():
query_spectrum = pd.Series([[1.1, 1.3, 1.7, 1.9], [10, 100, 1000, 100, 10]])
spectrum = pd.Series([[], []])
query_spectrum = pd.Series([pd.Series([1.1, 1.2, 1.3, 1.4, 1.5]), pd.Series([10, 100, 1000, 100, 10])])
spectrum = pd.Series([pd.Series([]), pd.Series([])])
row = pd.Series({'query_spectrum': query_spectrum, 'spectrum': spectrum})
out = sp.calc_jaccard_of_spectra(row)
assert out == 0.0

def test_calc_jaccard_of_spectra05():
query_spectrum = pd.Series([[], []])
spectrum = pd.Series([[1.1, 1.2, 1.3, 1.4, 1.5], [10, 100, 1000, 100, 10]])
query_spectrum = pd.Series([pd.Series([]), pd.Series([])])
spectrum = pd.Series([pd.Series([1.1, 1.2, 1.3, 1.4, 1.5]), pd.Series([10, 100, 1000, 100, 10])])
row = pd.Series({'query_spectrum': query_spectrum, 'spectrum': spectrum})
out = sp.calc_jaccard_of_spectra(row)
assert out == 0.0
Expand Down

0 comments on commit 3ce2546

Please sign in to comment.