Skip to content

Commit

Permalink
Test errors
Browse files Browse the repository at this point in the history
  • Loading branch information
elaubsch committed Feb 1, 2022
1 parent d7552c6 commit c5b51f8
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
21 changes: 21 additions & 0 deletions deepcell_spots/applications/polaris_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
from __future__ import division
from __future__ import print_function

import numpy as np
from tensorflow.python.platform import test

from deepcell.model_zoo import PanopticNet
Expand Down Expand Up @@ -71,3 +72,23 @@ def test_polaris_app(self):
self.assertEqual(len(shape), 2)
self.assertEqual(len(shape[0]), 4)
self.assertEqual(len(shape[1]), 4)

# test compartment error
with self.assertRaises(ValueError):
_ = Polaris(segmentation_compartment='x')

# test threshold error
app = Polaris()
spots_image = np.random.rand(1, 128, 128, 1)
with self.assertRaises(ValueError):
_ = app.predict(spots_image=spots_image, spots_threshold=1.1)
with self.assertRaises(ValueError):
_ = app.predict(spots_image=spots_image, spots_threshold=-1.1)

# test segmentation app error
app = Polaris(segmentation_compartment='None')
spots_image = np.random.rand(1, 128, 128, 1)
segmentation_image = np.random.rand(1, 128, 128, 1)
with self.assertRaises(ValueError):
_ = app.predict(spots_image=spots_image,
segmentation_image=segmentation_image)
9 changes: 9 additions & 0 deletions deepcell_spots/applications/spot_detection_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
from __future__ import division
from __future__ import print_function

import numpy as np
from tensorflow.python.platform import test

from deepcell_spots.dotnet import dot_net_2D
Expand All @@ -54,3 +55,11 @@ def test_spot_detection_app(self):
self.assertEqual(len(shape), 2) # 2 prediction heads
self.assertEqual(len(shape[0]), 4)
self.assertEqual(len(shape[1]), 4)

# test threshold error
app = SpotDetection()
spots_image = np.random.rand(1, 128, 128, 1)
with self.assertRaises(ValueError):
_ = app.predict(image=spots_image, threshold=1.1)
with self.assertRaises(ValueError):
_ = app.predict(image=spots_image, threshold=-1.1)

0 comments on commit c5b51f8

Please sign in to comment.