Skip to content

Commit

Permalink
Update tests'
Browse files Browse the repository at this point in the history
  • Loading branch information
asistradition committed Aug 12, 2021
1 parent a9676fd commit 2634914
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 6 deletions.
18 changes: 12 additions & 6 deletions inferelator/tests/test_results_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

import logging
logging.getLogger('matplotlib').setLevel(logging.ERROR)
import matplotlib.pyplot as plt


class TestResults(unittest.TestCase):
Expand Down Expand Up @@ -325,28 +326,33 @@ def test_plot_pr_curve(self):
temp_dir = tempfile.mkdtemp()
file_name = os.path.join(temp_dir, "pr_curve.pdf")
self.metric = self.metric([confidences, confidences], gs)
self.metric.output_curve_pdf(temp_dir, "pr_curve.pdf")
fig, ax = self.metric.output_curve_pdf(temp_dir, "pr_curve.pdf")
self.assertTrue(os.path.exists(file_name))

plt.close(fig)

os.remove(file_name)
self.assertFalse(os.path.exists(file_name))
self.metric.output_curve_pdf(output_dir=temp_dir, file_name="pr_curve.pdf")
fig, ax = self.metric.output_curve_pdf(output_dir=temp_dir, file_name="pr_curve.pdf")
self.assertTrue(os.path.exists(file_name))
plt.close(fig)

os.remove(file_name)
self.assertFalse(os.path.exists(file_name))
self.metric.curve_file_name = "pr_curve.pdf"
self.metric.output_curve_pdf(output_dir=temp_dir, file_name=None)
fig, ax = self.metric.output_curve_pdf(output_dir=temp_dir, file_name=None)
self.assertTrue(os.path.exists(file_name))
plt.close(fig)

os.remove(file_name)
self.metric.curve_file_name = None
self.assertFalse(os.path.exists(file_name))
self.metric.output_curve_pdf(output_dir=temp_dir, file_name=None)
fig, ax = self.metric.output_curve_pdf(output_dir=temp_dir, file_name=None)
self.assertFalse(os.path.exists(file_name))
plt.close(fig)

self.metric.output_curve_pdf(output_dir=None, file_name="pr_curve.pdf")
fig, ax = self.metric.output_curve_pdf(output_dir=None, file_name="pr_curve.pdf")
self.assertFalse(os.path.exists(file_name))
plt.close(fig)

shutil.rmtree(temp_dir)

Expand Down
24 changes: 24 additions & 0 deletions inferelator/tests/test_workflow_multitask.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,30 @@ def test_noise_prior(self):
np.testing.assert_array_almost_equal_nulp(self.workflow._task_objects[0].priors_data.values,
self.workflow._task_objects[1].priors_data.values)

def test_noise_prior_different(self):
self.workflow.add_prior_noise = 0.5

for tobj in self.workflow._task_objects:
np.testing.assert_array_almost_equal_nulp(tobj.priors_data.values, self.workflow.gold_standard.values)

self.workflow._task_objects[0].random_seed = 1000

self.workflow._process_default_priors()
self.workflow._process_task_priors()

for tobj in self.workflow._task_objects:

self.assertTrue(all(tobj.priors_data.columns == self.workflow.gold_standard.columns))
self.assertTrue(all(tobj.priors_data.index == self.workflow.gold_standard.index))

with self.assertRaises(AssertionError):
np.testing.assert_array_almost_equal_nulp(tobj.priors_data.values, self.workflow.gold_standard.values)


with self.assertRaises(AssertionError):
np.testing.assert_array_almost_equal_nulp(self.workflow._task_objects[0].priors_data.values,
self.workflow._task_objects[1].priors_data.values)

def test_noise_prior_base(self):
self.workflow.add_prior_noise = 0.5
self.workflow.add_prior_noise_to_task_priors = False
Expand Down

0 comments on commit 2634914

Please sign in to comment.