diff --git a/src/pynwb/base.py b/src/pynwb/base.py index cf286b2e1..eb78a031d 100644 --- a/src/pynwb/base.py +++ b/src/pynwb/base.py @@ -51,6 +51,7 @@ def add_container(self, **kwargs): Add an NWBContainer to this ProcessingModule ''' warn("add_container is deprecated. Use add instead.", DeprecationWarning) + self.add(kwargs['container']) @docval({'name': 'container_name', 'type': str, 'doc': 'the name of the NWBContainer to retrieve'}) def get_container(self, **kwargs): diff --git a/src/pynwb/core.py b/src/pynwb/core.py index d889474a1..1647d8f4e 100644 --- a/src/pynwb/core.py +++ b/src/pynwb/core.py @@ -133,18 +133,17 @@ def __init__(self, **kwargs): "Use description instead.") ) if notes != '' and description is not None: - self._error_on_new_warn_on_construct( - error_msg='Cannot provide both notes and description to ScratchData.__init__. The description ' - 'argument is recommended.' - ) + raise ValueError('Cannot provide both notes and description to ScratchData.__init__. The description ' + 'argument is recommended.') description = notes if not description: - self._error_on_new_warn_on_construct(error_msg='ScratchData.description is required by PyNWB > 3.0.') + self._error_on_new_warn_on_construct(error_msg='ScratchData.description is required.') self.description = description @property def notes(self): warn('Use of ScratchData.notes has been deprecated. Use ScratchData.description instead.', DeprecationWarning) + return self.description @notes.setter def notes(self, value): diff --git a/src/pynwb/file.py b/src/pynwb/file.py index f0233160e..1a8ee28f6 100644 --- a/src/pynwb/file.py +++ b/src/pynwb/file.py @@ -1053,6 +1053,8 @@ def add_scratch(self, **kwargs): if notes is not None or table_description != '': warn(('Use of the `notes` or `table_description` argument is deprecated. ' 'Use the `description` argument instead.'), DeprecationWarning) + if description is not None: + raise ValueError('Cannot call add_scratch with (notes or table_description) and description') if isinstance(data, (str, int, float, bytes, np.ndarray, list, tuple, pd.DataFrame)): if name is None: diff --git a/tests/integration/hdf5/test_ecephys.py b/tests/integration/hdf5/test_ecephys.py index 2ba9fb093..eafdf5d94 100644 --- a/tests/integration/hdf5/test_ecephys.py +++ b/tests/integration/hdf5/test_ecephys.py @@ -180,7 +180,7 @@ def setUpContainer(self): with self.assertRaisesWith(ValueError, error_msg): Clustering(**kwargs) - # create object in construct mode, modelling the behavior of the ObjectMapper on read + # create object in construct mode, modeling the behavior of the ObjectMapper on read obj = Clustering.__new__(Clustering, in_construct_mode=True) with self.assertWarnsWith(warn_type=UserWarning, exc_msg=error_msg): obj.__init__(**kwargs) @@ -249,7 +249,7 @@ def setUpContainer(self): with self.assertRaisesWith(ValueError, msg): cw = ClusterWaveforms(self.clustering, 'filtering', means, stdevs) - # create object in construct mode, modelling the behavior of the ObjectMapper on read + # create object in construct mode, modeling the behavior of the ObjectMapper on read cw = ClusterWaveforms.__new__(ClusterWaveforms, container_source=None, parent=None, diff --git a/tests/integration/hdf5/test_icephys.py b/tests/integration/hdf5/test_icephys.py index 71840ec49..17281b7ec 100644 --- a/tests/integration/hdf5/test_icephys.py +++ b/tests/integration/hdf5/test_icephys.py @@ -153,7 +153,7 @@ def setUpContainer(self): starting_time=123.6, rate=10e3, electrode=self.elec, gain=0.126, stimulus_description="gotcha ya!", sweep_number=np.uint(4711)) - # create the sweeptable in construct mode, modelling the behavior of the ObjectMapper on read + # create the sweeptable in construct mode, modeling the behavior of the ObjectMapper on read sweeptable = SweepTable.__new__(SweepTable) sweeptable._in_construct_mode = True msg = ("SweepTable is deprecated. Use the IntracellularRecordingsTable instead. " @@ -228,7 +228,7 @@ def setUpContainer(self): starting_time=123.6, rate=10e3, electrode=self.elec, gain=0.126, stimulus_description="gotcha ya!", sweep_number=np.uint(4712)) - # create the sweeptable in construct mode, modelling the behavior of the ObjectMapper on read + # create the sweeptable in construct mode, modeling the behavior of the ObjectMapper on read sweeptable = SweepTable.__new__(SweepTable) sweeptable._in_construct_mode = True msg = ("SweepTable is deprecated. Use the IntracellularRecordingsTable instead. " diff --git a/tests/unit/test_ecephys.py b/tests/unit/test_ecephys.py index 43d00ba5d..147268931 100644 --- a/tests/unit/test_ecephys.py +++ b/tests/unit/test_ecephys.py @@ -287,7 +287,7 @@ def test_init(self): with self.assertRaisesWith(ValueError, error_msg): cc = Clustering(**kwargs) - # create object in construct mode, modelling the behavior of the ObjectMapper on read + # create object in construct mode, modeling the behavior of the ObjectMapper on read cc = Clustering.__new__(Clustering, in_construct_mode=True) with self.assertWarnsWith(warn_type=UserWarning, exc_msg=error_msg): cc.__init__(**kwargs) @@ -305,7 +305,7 @@ def test_init(self): num = [3, 4] peak_over_rms = [5.3, 6.3] - # create object in construct mode, modelling the behavior of the ObjectMapper on read + # create object in construct mode, modeling the behavior of the ObjectMapper on read error_msg = "The Clustering neurodata type is deprecated. Use pynwb.misc.Units or NWBFile.units instead" cc = Clustering.__new__(Clustering, container_source=None, @@ -320,7 +320,7 @@ def test_init(self): with self.assertRaisesWith(ValueError, error_msg): cw = ClusterWaveforms(cc, 'filtering', means, stdevs) - # create object in construct mode, modelling the behavior of the ObjectMapper on read + # create object in construct mode, modeling the behavior of the ObjectMapper on read cw = ClusterWaveforms.__new__(ClusterWaveforms, container_source=None, parent=None, diff --git a/tests/unit/test_file.py b/tests/unit/test_file.py index f8daa2833..cc0ac72ec 100644 --- a/tests/unit/test_file.py +++ b/tests/unit/test_file.py @@ -134,7 +134,7 @@ def test_access_processing(self): with self.assertRaisesWith(ValueError, msg): self.nwbfile.modules['test_mod'] - # create object in construct mode, modelling the behavior of the ObjectMapper on read + # create object in construct mode, modeling the behavior of the ObjectMapper on read self.nwbfile._in_construct_mode = True with self.assertWarnsWith(warn_type=UserWarning, exc_msg=msg): modules = self.nwbfile.modules['test_mod'] diff --git a/tests/unit/test_icephys.py b/tests/unit/test_icephys.py index 901f93c14..ec0d68e77 100644 --- a/tests/unit/test_icephys.py +++ b/tests/unit/test_icephys.py @@ -39,14 +39,14 @@ class NWBFileICEphys(TestCase): def setUp(self): self.icephys_electrode = GetElectrode() - def test_sweep_table_deprectation_warn(self): + def test_sweep_table_deprecation_warn(self): msg = ("SweepTable is deprecated. Use the IntracellularRecordingsTable instead. " "See also the NWBFile.add_intracellular_recordings function.") with self.assertRaisesWith(ValueError, msg): SweepTable() - # create object in construct mode, modelling the behavior of the ObjectMapper on read + # create object in construct mode, modeling the behavior of the ObjectMapper on read sweepT = SweepTable.__new__(SweepTable, in_construct_mode=True) with self.assertWarnsWith(warn_type=UserWarning, exc_msg=msg): sweepT.__init__() @@ -60,7 +60,7 @@ def test_sweep_table_deprectation_warn(self): with self.assertRaisesWith(ValueError, msg): NWBFile(**kwargs) - # create object in construct mode, modelling the behavior of the ObjectMapper on read + # create object in construct mode, modeling the behavior of the ObjectMapper on read nwbfile = NWBFile.__new__(NWBFile, in_construct_mode=True) with self.assertWarnsWith(warn_type=UserWarning, exc_msg=msg): @@ -76,7 +76,7 @@ def test_ic_electrodes_parameter_deprecation(self): with self.assertRaisesWith(ValueError, msg): NWBFile(**kwargs) - # create object in construct mode, modelling the behavior of the ObjectMapper on read + # create object in construct mode, modeling the behavior of the ObjectMapper on read nwbfile = NWBFile.__new__(NWBFile, in_construct_mode=True) with self.assertWarnsWith(warn_type=UserWarning, exc_msg=msg): nwbfile.__init__(**kwargs) diff --git a/tests/unit/test_icephys_metadata_tables.py b/tests/unit/test_icephys_metadata_tables.py index af8f871cb..ba8d866fb 100644 --- a/tests/unit/test_icephys_metadata_tables.py +++ b/tests/unit/test_icephys_metadata_tables.py @@ -1169,7 +1169,7 @@ def test_deprecate_sweeptable_on_add_stimulus_template(self): nwbfile.add_stimulus_template(local_stimulus, use_sweep_table=True) # NOTE - the sweep table creation will error but the stimulus template will still be added - # create object in construct mode, modelling the behavior of the ObjectMapper on read + # create object in construct mode, modeling the behavior of the ObjectMapper on read nwbfile._in_construct_mode = True with self.assertWarnsWith(warn_type=UserWarning, exc_msg=msg): nwbfile.add_stimulus_template(local_stimulus2, use_sweep_table=True) @@ -1239,7 +1239,7 @@ def test_deprecate_sweepstable_on_init(self): with self.assertRaisesWith(ValueError, msg): nwbfile = NWBFile(**kwargs) - # create object in construct mode, modelling the behavior of the ObjectMapper on read + # create object in construct mode, modeling the behavior of the ObjectMapper on read nwbfile = NWBFile.__new__(NWBFile, in_construct_mode=True) with self.assertWarnsWith(warn_type=UserWarning, exc_msg=msg): nwbfile.__init__(**kwargs) @@ -1250,7 +1250,7 @@ def test_deprecate_sweepstable_on_init(self): stimulus = self.__get_stimulus(electrode=electrode) nwbfile.add_stimulus(stimulus, use_sweep_table=True) - def test_deprectation_icephys_filtering_on_init(self): + def test_deprecation_icephys_filtering_on_init(self): kwargs = dict(session_description='my first synthetic recording', identifier='EXAMPLE_ID', session_start_time=datetime.now(tzlocal()), @@ -1261,7 +1261,7 @@ def test_deprectation_icephys_filtering_on_init(self): with self.assertRaisesWith(ValueError, msg): nwbfile = NWBFile(**kwargs) - # create object in construct mode, modelling the behavior of the ObjectMapper on read + # create object in construct mode, modeling the behavior of the ObjectMapper on read nwbfile = NWBFile.__new__(NWBFile, in_construct_mode=True) with self.assertWarnsWith(warn_type=UserWarning, exc_msg=msg): nwbfile.__init__(**kwargs) @@ -1281,7 +1281,7 @@ def test_icephys_filtering_roundtrip(self): with self.assertRaisesWith(ValueError, msg): nwbfile.icephys_filtering = 'test filtering' - # create object in construct mode, modelling the behavior of the ObjectMapper on read + # create object in construct mode, modeling the behavior of the ObjectMapper on read nwbfile._in_construct_mode = True with self.assertWarnsWith(warn_type=UserWarning, exc_msg=msg): nwbfile.icephys_filtering = 'test filtering' diff --git a/tests/unit/test_image.py b/tests/unit/test_image.py index 20d157ba3..457888d9a 100644 --- a/tests/unit/test_image.py +++ b/tests/unit/test_image.py @@ -154,7 +154,7 @@ def test_external_file_with_incorrect_starting_frame_construct_mode(self): "ImageSeries 'test_iS': The number of frame indices in " "'starting_frame' should have the same length as 'external_file'." ) - # Create the image series in construct mode, modelling the behavior + # Create the image series in construct mode, modeling the behavior # of the ObjectMapper on read while avoiding having to create, write, # and read and entire NWB file obj = ImageSeries.__new__(ImageSeries, @@ -255,7 +255,7 @@ def test_external_file_default_format(self): with self.assertRaisesWith(ValueError, msg): ImageSeries(**kwargs) - # create object in construct mode, modelling the behavior of the ObjectMapper on read + # create object in construct mode, modeling the behavior of the ObjectMapper on read iS = ImageSeries.__new__(ImageSeries, in_construct_mode=True) with self.assertWarnsWith(warn_type=UserWarning, exc_msg=msg): iS.__init__(**kwargs) @@ -352,7 +352,7 @@ def test_init_bad_unit(self): with self.assertRaisesWith(ValueError, msg): IndexSeries(**kwargs) - # create object in construct mode, modelling the behavior of the ObjectMapper on read + # create object in construct mode, modeling the behavior of the ObjectMapper on read iS = IndexSeries.__new__(IndexSeries, in_construct_mode=True) with self.assertWarnsWith(warn_type=UserWarning, exc_msg=msg): iS.__init__(**kwargs) @@ -377,7 +377,7 @@ def test_init_indexed_ts(self): with self.assertRaisesWith(ValueError, msg): IndexSeries(**kwargs) - # create object in construct mode, modelling the behavior of the ObjectMapper on read + # create object in construct mode, modeling the behavior of the ObjectMapper on read iS = IndexSeries.__new__(IndexSeries, in_construct_mode=True) with self.assertWarnsWith(warn_type=UserWarning, exc_msg=msg): iS.__init__(**kwargs) diff --git a/tests/unit/test_ophys.py b/tests/unit/test_ophys.py index 2f268de61..9d4bf5ee6 100644 --- a/tests/unit/test_ophys.py +++ b/tests/unit/test_ophys.py @@ -146,7 +146,7 @@ def test_manifold_deprecated(self): with self.assertRaisesWith(ValueError, msg): ImagingPlane(**kwargs) - # create object in construct mode, modelling the behavior of the ObjectMapper on read + # create object in construct mode, modeling the behavior of the ObjectMapper on read obj = ImagingPlane.__new__(ImagingPlane, in_construct_mode=True) with self.assertWarnsWith(warn_type=UserWarning, exc_msg=msg): obj.__init__(**kwargs) @@ -168,7 +168,7 @@ def test_conversion_deprecated(self): with self.assertRaisesWith(ValueError, msg): ImagingPlane(**kwargs) - # create object in construct mode, modelling the behavior of the ObjectMapper on read + # create object in construct mode, modeling the behavior of the ObjectMapper on read obj = ImagingPlane.__new__(ImagingPlane, in_construct_mode=True) with self.assertWarnsWith(warn_type=UserWarning, exc_msg=msg): obj.__init__(**kwargs) @@ -191,7 +191,7 @@ def test_unit_deprecated(self): with self.assertRaisesWith(ValueError, msg): ImagingPlane(**kwargs) - # create object in construct mode, modelling the behavior of the ObjectMapper on read + # create object in construct mode, modeling the behavior of the ObjectMapper on read obj = ImagingPlane.__new__(ImagingPlane, in_construct_mode=True) with self.assertWarnsWith(warn_type=UserWarning, exc_msg=msg): obj.__init__(**kwargs) diff --git a/tests/unit/test_scratch.py b/tests/unit/test_scratch.py index 7cb678199..5bde67050 100644 --- a/tests/unit/test_scratch.py +++ b/tests/unit/test_scratch.py @@ -33,7 +33,7 @@ def test_scratch_notes_deprecation(self): with self.assertRaisesWith(ValueError, msg): ScratchData(name='test', data=[1, 2, 3, 4, 5], notes='test notes') - # create object in construct mode, modelling the behavior of the ObjectMapper on read + # create object in construct mode, modeling the behavior of the ObjectMapper on read data = ScratchData.__new__(ScratchData, in_construct_mode=True) with self.assertWarnsWith(UserWarning, msg): data.__init__(name='test', data=[1, 2, 3, 4, 5], notes='test notes')