Skip to content

Commit

Permalink
Partial #16 - Add more tests for thresholding and toolbox
Browse files Browse the repository at this point in the history
  • Loading branch information
FloBay committed May 26, 2024
1 parent e357485 commit 2d9bd2c
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 0 deletions.
41 changes: 41 additions & 0 deletions tests/unit/test_thresholding.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,5 +218,46 @@ def test_alpha_value(self):
pass


class TestSAMcorrection:

def test_single_value_input(self):
f_values = 10
curve_fold_change = 1
s0 = 0
f_adj = thresholding.sam_correction(f_values, curve_fold_change, s0)
assert np.isclose(f_values, f_adj)

def test_array_input(self):
f_values = [10, 1, 0]
curve_fold_changes = [1, 2, 3]
s0s = [0, 0, 0]
f_adjs = thresholding.sam_correction(f_values, curve_fold_changes, s0s)
assert all(np.isclose(f_values, f_adjs))

def test_different_s0(self):
f_value = 100
curve_fold_change = 1
s0s = [np.inf, 0.9, 0.1, 0]
expected_f_adjs = [ 0, 1, 25, 100]
f_adjs = thresholding.sam_correction(f_value, curve_fold_change, s0s)
assert all(np.isclose(expected_f_adjs, f_adjs))

def test_different_fold_changes(self):
f_value = 100
curve_fold_changes = [np.inf, 10, 1/.9, 0]
s0 = 1
expected_f_adjs = [100, 25, 1, 0]
f_adjs = thresholding.sam_correction(f_value, curve_fold_changes, s0)
assert all(np.isclose(expected_f_adjs, f_adjs))

def test_different_fvalues(self):
f_values = [np.inf, 400, 100, 25, 4, 0]
curve_fold_change = 1
s0 = 0.1
expected_f_adjs = np.array([1/0.1, 1/0.15, 1/0.2, 1/0.3, 1/0.6, 0])**2
f_adjs = thresholding.sam_correction(f_values, curve_fold_change, s0)
assert all(np.isclose(expected_f_adjs, f_adjs))


class TestDefineRegulatedCurves:
pass
13 changes: 13 additions & 0 deletions tests/unit/test_toolbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,3 +179,16 @@ def test_twenty(self):
x = 11.1
expected = 10.0
assert expected == toolbox.rounddown(x)


class TestColNameGenerator:

def test_with_numbers(self):
expected = ['Test 0', 'Test 1', 'Test 2', 'Test 3', 'Test 4', 'Test 5']
out = toolbox.build_col_names('Test {}', range(6))
assert all(out == expected)

def test_with_strings(self):
expected = ['Test A', 'Test B', 'Test C', 'Test D']
out = toolbox.build_col_names('Test {}', [*'ABCD'])
assert all(out == expected)

0 comments on commit 2d9bd2c

Please sign in to comment.