From 4c5fa1e13411e4c5f751395e2c9cdee64647617c Mon Sep 17 00:00:00 2001 From: Cody Baker Date: Tue, 27 Aug 2024 09:58:47 -0400 Subject: [PATCH] start adding tests --- src/pynwb/ndx_microscopy/testing/_mock.py | 84 ++++++++++++++++++++--- 1 file changed, 73 insertions(+), 11 deletions(-) diff --git a/src/pynwb/ndx_microscopy/testing/_mock.py b/src/pynwb/ndx_microscopy/testing/_mock.py index 60944e2..ea241ec 100644 --- a/src/pynwb/ndx_microscopy/testing/_mock.py +++ b/src/pynwb/ndx_microscopy/testing/_mock.py @@ -11,7 +11,7 @@ def mock_Microscope( *, name: Optional[str] = None, - description: str = "This is a mock instance of a Microscope type to be used for rapid testing.", + description: str = "A mock instance of a Microscope type to be used for rapid testing.", manufacturer: str = "A fake manufacturer of the mock microscope.", model: str = "A fake model of the mock microscope.", ) -> ndx_microscopy.Microscope: @@ -27,7 +27,7 @@ def mock_Microscope( def mock_MicroscopyLightSource( *, name: Optional[str] = None, - description: str = "This is a mock instance of a MicroscopyLightSource type to be used for rapid testing.", + description: str = "A mock instance of a MicroscopyLightSource type to be used for rapid testing.", manufacturer: str = "A fake manufacturer of the mock light source.", model: str = "A fake model of the mock light source.", filter_description: str = "A description about the fake filter used by the mock light source.", @@ -57,7 +57,7 @@ def mock_MicroscopyLightSource( def mock_MicroscopyOpticalChannel( *, name: Optional[str] = None, - description: str = "This is a mock instance of a MicroscopyOpticalChannel type to be used for rapid testing.", + description: str = "A mock instance of a MicroscopyOpticalChannel type to be used for rapid testing.", indicator: str = "The indicator targeted by the mock optical channel.", filter_description: str = "A description about the fake filter used by the mock optical channel.", emission_wavelength_in_nm: float = 450.0, @@ -76,7 +76,7 @@ def mock_PlanarImagingSpace( *, microscope: ndx_microscopy.Microscope, name: Optional[str] = None, - description: str = "This is a mock instance of a PlanarImagingSpace type to be used for rapid testing.", + description: str = "A mock instance of a PlanarImagingSpace type to be used for rapid testing.", origin_coordinates: Tuple[float, float, float] = (-1.2, -0.6, -2), grid_spacing_in_um: Tuple[float, float, float] = (20, 20), location: str = "The location targeted by the mock imaging space.", @@ -98,7 +98,7 @@ def mock_VolumetricImagingSpace( *, microscope: ndx_microscopy.Microscope, name: Optional[str] = None, - description: str = "This is a mock instance of a VolumetricImagingSpace type to be used for rapid testing.", + description: str = "A mock instance of a VolumetricImagingSpace type to be used for rapid testing.", origin_coordinates: Tuple[float, float, float] = (-1.2, -0.6, -2), grid_spacing_in_um: Tuple[float, float, float] = (20, 20, 50), location: str = "The location targeted by the mock imaging space.", @@ -140,7 +140,7 @@ def mock_MicroscopyPlaneSegmentation( *, imaging_space: ndx_microscopy.ImagingSpace, name: Optional[str] = None, - description: str = "This is a mock instance of a MicroscopyPlaneSegmentation type to be used for rapid testing.", + description: str = "A mock instance of a MicroscopyPlaneSegmentation type to be used for rapid testing.", number_of_rois: int = 5, image_shape: Tuple[int, int] = (10, 10), ) -> ndx_microscopy.MicroscopyPlaneSegmentation: @@ -166,7 +166,7 @@ def mock_PlanarMicroscopySeries( imaging_space: ndx_microscopy.PlanarImagingSpace, optical_channel: ndx_microscopy.MicroscopyOpticalChannel, name: Optional[str] = None, - description: str = "This is a mock instance of a PlanarMicroscopySeries type to be used for rapid testing.", + description: str = "A mock instance of a PlanarMicroscopySeries type to be used for rapid testing.", data: Optional[np.ndarray] = None, unit: str = "a.u.", conversion: float = 1.0, @@ -221,7 +221,7 @@ def mock_VariableDepthMicroscopySeries( imaging_space: ndx_microscopy.PlanarImagingSpace, optical_channel: ndx_microscopy.MicroscopyOpticalChannel, name: Optional[str] = None, - description: str = "This is a mock instance of a PlanarMicroscopySeries type to be used for rapid testing.", + description: str = "A mock instance of a PlanarMicroscopySeries type to be used for rapid testing.", data: Optional[np.ndarray] = None, depth_per_frame_in_um: Optional[np.ndarray] = None, unit: str = "a.u.", @@ -284,7 +284,7 @@ def mock_VolumetricMicroscopySeries( imaging_space: ndx_microscopy.VolumetricImagingSpace, optical_channel: ndx_microscopy.MicroscopyOpticalChannel, name: Optional[str] = None, - description: str = "This is a mock instance of a VolumetricMicroscopySeries type to be used for rapid testing.", + description: str = "A mock instance of a VolumetricMicroscopySeries type to be used for rapid testing.", data: Optional[np.ndarray] = None, unit: str = "a.u.", conversion: float = 1.0, @@ -339,7 +339,7 @@ def mock_MultiChannelMicroscopyVolume( light_sources: pynwb.base.VectorData, optical_channels: pynwb.base.VectorData, name: Optional[str] = None, - description: str = "This is a mock instance of a MultiChannelMicroscopyVolume type to be used for rapid testing.", + description: str = "A mock instance of a MultiChannelMicroscopyVolume type to be used for rapid testing.", data: Optional[np.ndarray] = None, unit: str = "n.a.", conversion: float = 1.0, @@ -363,6 +363,68 @@ def mock_MultiChannelMicroscopyVolume( return volumetric_microscopy_series +def mock_MicroscopyResponseSeries( + *, + table_region: pynwb.core.DynamicTableRegion, + name: Optional[str] = None, + description: str = "A mock instance of a MicroscopyResponseSeries type to be used for rapid testing.", + data: Optional[np.ndarray] = None, + unit: str = "a.u.", + conversion: float = 1.0, + offset: float = 0.0, + starting_time: Optional[float] = None, + rate: Optional[float] = None, + timestamps: Optional[np.ndarray] = None, +) -> ndx_microscopy.MicroscopyResponseSeries: + series_name = name or name_generator("MicroscopyResponseSeries") + + response_series = ndx_microscopy.MicroscopyResponseSeries( + name=series_name, + description=description, + table_region=table_region, + data=data, + unit=unit, + conversion=conversion, + offset=offset, + starting_time=starting_time, + rate=rate, + timestamps=timestamps, + ) + + return response_series + + +def mock_MicroscopyResponseSeriesContainer( + *, + table_region: pynwb.core.DynamicTableRegion, + name: Optional[str] = None, + description: str = "A mock instance of a MicroscopyResponseSeriesContainer type to be used for rapid testing.", + data: Optional[np.ndarray] = None, + unit: str = "a.u.", + conversion: float = 1.0, + offset: float = 0.0, + starting_time: Optional[float] = None, + rate: Optional[float] = None, + timestamps: Optional[np.ndarray] = None, +) -> ndx_microscopy.MicroscopyResponseSeriesContainer: + series_name = name or name_generator("MicroscopyResponseSeries") + + response_series = ndx_microscopy.MicroscopyResponseSeries( + name=series_name, + description=description, + table_region=table_region, + data=data, + unit=unit, + conversion=conversion, + offset=offset, + starting_time=starting_time, + rate=rate, + timestamps=timestamps, + ) + + return response_series + + def mock_VariableDepthMultiChannelMicroscopyVolume( *, microscope: ndx_microscopy.Microscope, @@ -370,7 +432,7 @@ def mock_VariableDepthMultiChannelMicroscopyVolume( light_sources: pynwb.base.VectorData, optical_channels: pynwb.base.VectorData, name: Optional[str] = None, - description: str = "This is a mock instance of a MultiChannelMicroscopyVolume type to be used for rapid testing.", + description: str = "A mock instance of a MultiChannelMicroscopyVolume type to be used for rapid testing.", data: Optional[np.ndarray] = None, depth_per_frame_in_um: Optional[np.ndarray] = None, unit: str = "n.a.",