Skip to content

Commit

Permalink
Improve plane seg coverage (#187)
Browse files Browse the repository at this point in the history
* move tests outside the nwbwidgets package

* improve plane segmentation coverage

* improve plane segmentation coverage

* test show_timeseries_mpl
  • Loading branch information
bendichter committed Jan 6, 2022
1 parent 0b924c6 commit b2fee99
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 5 deletions.
14 changes: 9 additions & 5 deletions test/test_ophys.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,28 +73,30 @@ def setUpClass(self):
"2d_plane_seg",
self.image_series,
)
self.ps2.add_column("type", "desc")
self.ps2.add_column("type2", "desc")

w, h = 3, 3
img_mask1 = np.zeros((w, h))
img_mask1[0, 0] = 1.1
img_mask1[1, 1] = 1.2
img_mask1[2, 2] = 1.3
self.ps2.add_roi(image_mask=img_mask1)
self.ps2.add_roi(image_mask=img_mask1, type=1, type2=0)

img_mask2 = np.zeros((w, h))
img_mask2[0, 0] = 2.1
img_mask2[1, 1] = 2.2
self.ps2.add_roi(image_mask=img_mask2)
self.ps2.add_roi(image_mask=img_mask2, type=1, type2=1)

img_mask2 = np.zeros((w, h))
img_mask2[0, 0] = 9.1
img_mask2[1, 1] = 10.2
self.ps2.add_roi(image_mask=img_mask2)
self.ps2.add_roi(image_mask=img_mask2, type=2, type2=0)

img_mask2 = np.zeros((w, h))
img_mask2[0, 0] = 3.5
img_mask2[1, 1] = 5.6
self.ps2.add_roi(image_mask=img_mask2)
self.ps2.add_roi(image_mask=img_mask2, type=2, type2=1)

fl = Fluorescence()
rt_region = self.ps2.create_roi_table_region(
Expand Down Expand Up @@ -130,12 +132,14 @@ def test_show_3d_two_photon_series(self):
def test_show_df_over_f(self):
dff = show_df_over_f(self.df_over_f, default_neurodata_vis_spec)
assert isinstance(dff, widgets.Widget)
dff.controls['gas'].window = [1,2]
dff.controls['gas'].window = [1, 2]

def test_plane_segmentation_2d_widget(self):
wid = PlaneSegmentation2DWidget(self.ps2)
assert isinstance(wid, widgets.Widget)
wid.button.click()
wid.cat_controller.value = "type"
wid.cat_controller.value = "type2"

def test_show_plane_segmentation_3d_mask(self):
ps3 = PlaneSegmentation(
Expand Down
15 changes: 15 additions & 0 deletions test/test_timeseries.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
SeparateTracesPlotlyWidget,
get_timeseries_tt,
show_indexed_timeseries_plotly,
show_timeseries_mpl,
)
from pynwb import TimeSeries
from pynwb.epoch import TimeIntervals
Expand All @@ -33,6 +34,20 @@ def test_timeseries_widget():
BaseGroupedTraceWidget(ts)


def test_show_timeseries_mpl():

ts = TimeSeries(
name="name",
description="no description",
data=np.array([[1.0, 2.0, 3.0, 4.0], [11.0, 12.0, 13.0, 14.0]]),
rate=100.0,
unit="m",
)

show_timeseries_mpl(ts)
show_timeseries_mpl(ts, time_window=(0.0, 1.0))


class TestTracesPlotlyWidget(unittest.TestCase):
def setUp(self):
data = np.random.rand(160, 3)
Expand Down

0 comments on commit b2fee99

Please sign in to comment.