Skip to content

Commit

Permalink
Change spectral object as numpy array instead of pandas series for te…
Browse files Browse the repository at this point in the history
…sting
  • Loading branch information
bkieft-usa committed Jul 24, 2024
1 parent a0eec0e commit a542d3f
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 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([pd.Series([1.1, 1.2, 1.3, 1.4, 1.5]), pd.Series([10, 100, 1000, 100, 10])])
spectrum = np.array([[1.1, 1.2, 1.3, 1.4, 1.5], [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([pd.Series([1.1, 1.2, 1.3, 1.4, 1.5]), pd.Series([10, 100, 1000, 100, 10])])
spectrum = np.array([[1.1, 1.2, 1.3, 1.4, 1.5], [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([pd.Series([1.1, 1.2, 1.3, 1.4, 1.5]), pd.Series([10, 100, 1000, 100, 10])])
spectrum = np.array([[1.1, 1.2, 1.3, 1.4, 1.5], [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([pd.Series([]),pd.Series([])])
spectrum = np.array([])
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([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])])
query_spectrum = np.array([[1.1, 1.2, 1.3, 1.4, 1.5], [10, 100, 1000, 100, 10]])
spectrum = np.array([[1.1, 1.2, 1.3, 1.4, 1.5], [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([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])])
query_spectrum = np.array([[1.1], [10]])
spectrum = np.array([[1.1, 1.2, 1.3, 1.4, 1.5], [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([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])])
query_spectrum = np.array([[1.1, 1.3, 1.7, 1.9, 2.1], [10, 100, 1000, 100, 10]])
spectrum = np.array([[1.1, 1.2, 1.3, 1.4, 1.5], [10, 100, 1000, 100, 10]])
row = pd.Series({'query_spectrum': query_spectrum, 'spectrum': spectrum})
out = sp.calc_jaccard_of_spectra(row)
assert out == 0.25

def test_calc_jaccard_of_spectra04():
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([])])
query_spectrum = np.array([[1.1, 1.2, 1.3, 1.4, 1.5], [10, 100, 1000, 100, 10]])
spectrum = np.array([])
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([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])])
query_spectrum = np.array([])
spectrum = np.array([[1.1, 1.2, 1.3, 1.4, 1.5], [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 a542d3f

Please sign in to comment.