diff --git a/CHANGELOG.md b/CHANGELOG.md index 191f67e29..065ebc0c5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ ### Breaking changes ### Enhancements and minor changes +- Added warnings when using positional arguments in `Container` constructor methods. Positional arguments will raise errors in the next major release. @stephprince [#1972](https://github.com/NeurodataWithoutBorders/pynwb/pull/1972) ## PyNWB 2.8.3 (Upcoming) diff --git a/src/pynwb/base.py b/src/pynwb/base.py index 8b4daf48f..0bc5d22d7 100644 --- a/src/pynwb/base.py +++ b/src/pynwb/base.py @@ -6,7 +6,7 @@ from hdmf.utils import docval, popargs_to_dict, get_docval, popargs from hdmf.common import DynamicTable, VectorData -from hdmf.utils import get_data_shape +from hdmf.utils import get_data_shape, AllowPositional from . import register_class, CORE_NAMESPACE from .core import NWBDataInterface, MultiContainerInterface, NWBData @@ -33,7 +33,8 @@ class ProcessingModule(MultiContainerInterface): @docval({'name': 'name', 'type': str, 'doc': 'The name of this processing module'}, {'name': 'description', 'type': str, 'doc': 'Description of this processing module'}, {'name': 'data_interfaces', 'type': (list, tuple, dict), - 'doc': 'NWBDataInterfaces that belong to this ProcessingModule', 'default': None}) + 'doc': 'NWBDataInterfaces that belong to this ProcessingModule', 'default': None}, + allow_positional=AllowPositional.WARNING,) def __init__(self, **kwargs): description, data_interfaces = popargs("description", "data_interfaces", kwargs) super().__init__(**kwargs) @@ -143,7 +144,8 @@ class TimeSeries(NWBDataInterface): 'distinct moments in time. Times of image presentations would be "step" because the picture ' 'remains the same until the next time-point. This field is optional, but is useful in providing ' 'information about the underlying data. It may inform the way this data is interpreted, the way it ' - 'is visualized, and what analysis methods are applicable.'}) + 'is visualized, and what analysis methods are applicable.'}, + allow_positional=AllowPositional.WARNING,) def __init__(self, **kwargs): """Create a TimeSeries object """ @@ -375,7 +377,8 @@ class Image(NWBData): {'name': 'data', 'type': ('array_data', 'data'), 'doc': 'data of image. Dimensions: x, y [, r,g,b[,a]]', 'shape': ((None, None), (None, None, 3), (None, None, 4))}, {'name': 'resolution', 'type': float, 'doc': 'pixels / cm', 'default': None}, - {'name': 'description', 'type': str, 'doc': 'description of image', 'default': None}) + {'name': 'description', 'type': str, 'doc': 'description of image', 'default': None}, + allow_positional=AllowPositional.WARNING,) def __init__(self, **kwargs): args_to_set = popargs_to_dict(("resolution", "description"), kwargs) super().__init__(**kwargs) @@ -392,7 +395,8 @@ class ImageReferences(NWBData): __nwbfields__ = ('data', ) @docval({'name': 'name', 'type': str, 'doc': 'The name of this ImageReferences object.'}, - {'name': 'data', 'type': 'array_data', 'doc': 'The images in order.'},) + {'name': 'data', 'type': 'array_data', 'doc': 'The images in order.'}, + allow_positional=AllowPositional.WARNING,) def __init__(self, **kwargs): # NOTE we do not use the docval shape validator here because it will recognize a list of P MxN images as # having shape (P, M, N) @@ -424,7 +428,8 @@ class Images(MultiContainerInterface): {'name': 'images', 'type': 'array_data', 'doc': 'image objects', 'default': None}, {'name': 'description', 'type': str, 'doc': 'description of images', 'default': 'no description'}, {'name': 'order_of_images', 'type': ImageReferences, - 'doc': 'Ordered dataset of references to Image objects stored in the parent group.', 'default': None},) + 'doc': 'Ordered dataset of references to Image objects stored in the parent group.', 'default': None}, + allow_positional=AllowPositional.WARNING,) def __init__(self, **kwargs): args_to_set = popargs_to_dict(("description", "images", "order_of_images"), kwargs) @@ -617,7 +622,8 @@ class TimeSeriesReferenceVectorData(VectorData): 'default': "Column storing references to a TimeSeries (rows). For each TimeSeries this " "VectorData column stores the start_index and count to indicate the range in time " "to be selected as well as an object reference to the TimeSeries."}, - *get_docval(VectorData.__init__, 'data')) + *get_docval(VectorData.__init__, 'data'), + allow_positional=AllowPositional.WARNING,) def __init__(self, **kwargs): super().__init__(**kwargs) # CAUTION: Define any logic specific for init in the self._init_internal function, not here! diff --git a/src/pynwb/behavior.py b/src/pynwb/behavior.py index 1b3078535..170c9bc6c 100644 --- a/src/pynwb/behavior.py +++ b/src/pynwb/behavior.py @@ -1,6 +1,6 @@ import warnings -from hdmf.utils import docval, popargs, get_docval, get_data_shape +from hdmf.utils import docval, popargs, get_docval, get_data_shape, AllowPositional from . import register_class, CORE_NAMESPACE from .core import MultiContainerInterface @@ -33,13 +33,14 @@ class SpatialSeries(TimeSeries): {'name': 'unit', 'type': str, 'doc': 'The base unit of measurement (should be SI unit)', 'default': 'meters'}, *get_docval(TimeSeries.__init__, 'conversion', 'resolution', 'timestamps', 'starting_time', 'rate', - 'comments', 'description', 'control', 'control_description', 'offset')) + 'comments', 'description', 'control', 'control_description', 'offset'), + allow_positional=AllowPositional.WARNING,) def __init__(self, **kwargs): """ Create a SpatialSeries TimeSeries dataset """ - name, data, bounds, reference_frame, unit = popargs('name', 'data', 'bounds', 'reference_frame', 'unit', kwargs) - super().__init__(name, data, unit, **kwargs) + name, data, bounds, reference_frame = popargs('name', 'data', 'bounds', 'reference_frame', kwargs) + super().__init__(name=name, data=data, **kwargs) # NWB 2.5 restricts length of second dimension to be <= 3 allowed_data_shapes = ((None, ), (None, 1), (None, 2), (None, 3)) diff --git a/src/pynwb/core.py b/src/pynwb/core.py index f9ae2bd2f..59f849db8 100644 --- a/src/pynwb/core.py +++ b/src/pynwb/core.py @@ -6,7 +6,7 @@ from hdmf.container import AbstractContainer, MultiContainerInterface as hdmf_MultiContainerInterface, Table from hdmf.common import DynamicTable, DynamicTableRegion # noqa: F401 from hdmf.common import VectorData, VectorIndex, ElementIdentifiers # noqa: F401 -from hdmf.utils import docval, popargs +from hdmf.utils import docval, popargs, AllowPositional from hdmf.utils import LabelledDict # noqa: F401 from . import CORE_NAMESPACE, register_class @@ -78,7 +78,8 @@ class NWBDataInterface(NWBContainer): class NWBData(NWBMixin, Data): @docval({'name': 'name', 'type': str, 'doc': 'the name of this container'}, - {'name': 'data', 'type': ('scalar_data', 'array_data', 'data', Data), 'doc': 'the source of the data'}) + {'name': 'data', 'type': ('scalar_data', 'array_data', 'data', Data), 'doc': 'the source of the data'}, + allow_positional=AllowPositional.WARNING,) def __init__(self, **kwargs): super().__init__(**kwargs) self.__data = kwargs['data'] @@ -123,7 +124,8 @@ class ScratchData(NWBData): {'name': 'data', 'type': ('scalar_data', 'array_data', 'data', Data), 'doc': 'the source of the data'}, {'name': 'notes', 'type': str, 'doc': 'notes about the data. This argument will be deprecated. Use description instead', 'default': ''}, - {'name': 'description', 'type': str, 'doc': 'notes about the data', 'default': None}) + {'name': 'description', 'type': str, 'doc': 'notes about the data', 'default': None}, + allow_positional=AllowPositional.WARNING,) def __init__(self, **kwargs): notes, description = popargs('notes', 'description', kwargs) super().__init__(**kwargs) diff --git a/src/pynwb/device.py b/src/pynwb/device.py index 6fcd610c8..5df75688c 100644 --- a/src/pynwb/device.py +++ b/src/pynwb/device.py @@ -1,4 +1,4 @@ -from hdmf.utils import docval, popargs +from hdmf.utils import docval, popargs, AllowPositional from . import register_class, CORE_NAMESPACE from .core import NWBContainer @@ -19,7 +19,8 @@ class Device(NWBContainer): 'doc': 'Description of the device (e.g., model, firmware version, processing software version, etc.)', 'default': None}, {'name': 'manufacturer', 'type': str, 'doc': 'the name of the manufacturer of this device', - 'default': None}) + 'default': None}, + allow_positional=AllowPositional.WARNING,) def __init__(self, **kwargs): description, manufacturer = popargs('description', 'manufacturer', kwargs) super().__init__(**kwargs) diff --git a/src/pynwb/ecephys.py b/src/pynwb/ecephys.py index e6dadbe97..2bb4992a5 100644 --- a/src/pynwb/ecephys.py +++ b/src/pynwb/ecephys.py @@ -4,7 +4,7 @@ from hdmf.common import DynamicTableRegion from hdmf.data_utils import DataChunkIterator, assertEqualShape -from hdmf.utils import docval, popargs, get_docval, popargs_to_dict, get_data_shape +from hdmf.utils import docval, popargs, get_docval, popargs_to_dict, get_data_shape, AllowPositional from . import register_class, CORE_NAMESPACE from .base import TimeSeries @@ -29,7 +29,8 @@ class ElectrodeGroup(NWBContainer): {'name': 'position', 'type': 'array_data', 'doc': 'Compound dataset with stereotaxic position of this electrode group (x, y, z). ' 'The data array must have three elements or the dtype of the ' - 'array must be ``(float, float, float)``', 'default': None}) + 'array must be ``(float, float, float)``', 'default': None}, + allow_positional=AllowPositional.WARNING,) def __init__(self, **kwargs): args_to_set = popargs_to_dict(('description', 'location', 'device', 'position'), kwargs) super().__init__(**kwargs) @@ -91,7 +92,8 @@ class ElectricalSeries(TimeSeries): "filter is unknown, then this value could be 'Low-pass filter at 300 Hz'. If a non-standard filter " "type is used, provide as much detail about the filter properties as possible.", 'default': None}, *get_docval(TimeSeries.__init__, 'resolution', 'conversion', 'timestamps', 'starting_time', 'rate', - 'comments', 'description', 'control', 'control_description', 'offset')) + 'comments', 'description', 'control', 'control_description', 'offset'), + allow_positional=AllowPositional.WARNING,) def __init__(self, **kwargs): args_to_set = popargs_to_dict(('electrodes', 'channel_conversion', 'filtering'), kwargs) @@ -134,7 +136,8 @@ class SpikeEventSeries(ElectricalSeries): 'doc': 'Timestamps for samples stored in data'}, *get_docval(ElectricalSeries.__init__, 'electrodes'), # required *get_docval(ElectricalSeries.__init__, 'resolution', 'conversion', 'comments', 'description', 'control', - 'control_description', 'offset')) + 'control_description', 'offset'), + allow_positional=AllowPositional.WARNING,) def __init__(self, **kwargs): data = kwargs['data'] timestamps = kwargs['timestamps'] @@ -169,7 +172,8 @@ class EventDetection(NWBDataInterface): '(e.g., .25msec before action potential peak, zero-crossing time, etc). ' 'The index points to each event from the raw data'}, {'name': 'times', 'type': ('array_data', 'data'), 'doc': 'Timestamps of events, in Seconds'}, - {'name': 'name', 'type': str, 'doc': 'the name of this container', 'default': 'EventDetection'}) + {'name': 'name', 'type': str, 'doc': 'the name of this container', 'default': 'EventDetection'}, + allow_positional=AllowPositional.WARNING,) def __init__(self, **kwargs): args_to_set = popargs_to_dict(('detection_method', 'source_electricalseries', 'source_idx', 'times'), kwargs) super().__init__(**kwargs) @@ -320,7 +324,8 @@ class FeatureExtraction(NWBDataInterface): 'doc': 'The times of events that features correspond to'}, {'name': 'features', 'type': ('array_data', 'data'), 'shape': (None, None, None), 'doc': 'Features for each channel'}, - {'name': 'name', 'type': str, 'doc': 'the name of this container', 'default': 'FeatureExtraction'}) + {'name': 'name', 'type': str, 'doc': 'the name of this container', 'default': 'FeatureExtraction'}, + allow_positional=AllowPositional.WARNING,) def __init__(self, **kwargs): # get the inputs electrodes, description, times, features = popargs( diff --git a/src/pynwb/epoch.py b/src/pynwb/epoch.py index 9cccc5db5..1db797462 100644 --- a/src/pynwb/epoch.py +++ b/src/pynwb/epoch.py @@ -2,7 +2,7 @@ from hdmf.data_utils import DataIO from hdmf.common import DynamicTable -from hdmf.utils import docval, getargs, popargs, get_docval +from hdmf.utils import docval, getargs, popargs, get_docval, AllowPositional from . import register_class, CORE_NAMESPACE from .base import TimeSeries, TimeSeriesReferenceVectorData, TimeSeriesReference @@ -27,7 +27,8 @@ class TimeIntervals(DynamicTable): @docval({'name': 'name', 'type': str, 'doc': 'name of this TimeIntervals'}, # required {'name': 'description', 'type': str, 'doc': 'Description of this TimeIntervals', 'default': "experimental intervals"}, - *get_docval(DynamicTable.__init__, 'id', 'columns', 'colnames')) + *get_docval(DynamicTable.__init__, 'id', 'columns', 'colnames'), + allow_positional=AllowPositional.WARNING,) def __init__(self, **kwargs): super().__init__(**kwargs) diff --git a/src/pynwb/file.py b/src/pynwb/file.py index 7621df2ac..9d0f4d154 100644 --- a/src/pynwb/file.py +++ b/src/pynwb/file.py @@ -45,7 +45,8 @@ class LabMetaData(NWBContainer): tutorial. """ - @docval({'name': 'name', 'type': str, 'doc': 'name of lab metadata'}) + @docval({'name': 'name', 'type': str, 'doc': 'name of lab metadata'}, + allow_positional=AllowPositional.WARNING,) def __init__(self, **kwargs): super().__init__(**kwargs) @@ -107,6 +108,7 @@ class Subject(NWBContainer): {'name': 'date_of_birth', 'type': datetime, 'default': None, 'doc': 'The datetime of the date of birth. May be supplied instead of age.'}, {'name': 'strain', 'type': str, 'doc': 'The strain of the subject, e.g., "C57BL/6J"', 'default': None}, + allow_positional=AllowPositional.WARNING, ) def __init__(self, **kwargs): keys_to_set = ( @@ -940,7 +942,8 @@ def get_icephys_simultaneous_recordings(self): will return None if the table is currently not being used. """ if self.icephys_simultaneous_recordings is None: - self.icephys_simultaneous_recordings = SimultaneousRecordingsTable(self.get_intracellular_recordings()) + self.icephys_simultaneous_recordings = SimultaneousRecordingsTable( + intracellular_recordings_table=self.get_intracellular_recordings()) return self.icephys_simultaneous_recordings @docval(*get_docval(SimultaneousRecordingsTable.add_simultaneous_recording), @@ -963,7 +966,8 @@ def get_icephys_sequential_recordings(self): will return None if the table is currently not being used. """ if self.icephys_sequential_recordings is None: - self.icephys_sequential_recordings = SequentialRecordingsTable(self.get_icephys_simultaneous_recordings()) + self.icephys_sequential_recordings = SequentialRecordingsTable( + simultaneous_recordings_table=self.get_icephys_simultaneous_recordings()) return self.icephys_sequential_recordings @docval(*get_docval(SequentialRecordingsTable.add_sequential_recording), @@ -987,7 +991,8 @@ def get_icephys_repetitions(self): will return None if the table is currently not being used. """ if self.icephys_repetitions is None: - self.icephys_repetitions = RepetitionsTable(self.get_icephys_sequential_recordings()) + self.icephys_repetitions = RepetitionsTable( + sequential_recordings_table=self.get_icephys_sequential_recordings()) return self.icephys_repetitions @docval(*get_docval(RepetitionsTable.add_repetition), @@ -1010,7 +1015,8 @@ def get_icephys_experimental_conditions(self): will return None if the table is currently not being used. """ if self.icephys_experimental_conditions is None: - self.icephys_experimental_conditions = ExperimentalConditionsTable(self.get_icephys_repetitions()) + self.icephys_experimental_conditions = ExperimentalConditionsTable( + repetitions_table=self.get_icephys_repetitions()) return self.icephys_experimental_conditions @docval(*get_docval(ExperimentalConditionsTable.add_experimental_condition), diff --git a/src/pynwb/icephys.py b/src/pynwb/icephys.py index 3101649fd..4042260d3 100644 --- a/src/pynwb/icephys.py +++ b/src/pynwb/icephys.py @@ -4,7 +4,7 @@ import numpy as np from hdmf.common import DynamicTable, AlignedDynamicTable -from hdmf.utils import docval, popargs, popargs_to_dict, get_docval, getargs +from hdmf.utils import docval, popargs, popargs_to_dict, get_docval, getargs, AllowPositional from . import register_class, CORE_NAMESPACE from .base import TimeSeries, TimeSeriesReferenceVectorData @@ -51,7 +51,8 @@ class IntracellularElectrode(NWBContainer): {'name': 'resistance', 'type': str, 'doc': 'Electrode resistance, unit - Ohm.', 'default': None}, {'name': 'filtering', 'type': str, 'doc': 'Electrode specific filtering.', 'default': None}, {'name': 'initial_access_resistance', 'type': str, 'doc': 'Initial access resistance.', 'default': None}, - {'name': 'cell_id', 'type': str, 'doc': 'Unique ID of cell.', 'default': None} + {'name': 'cell_id', 'type': str, 'doc': 'Unique ID of cell.', 'default': None}, + allow_positional=AllowPositional.WARNING, ) def __init__(self, **kwargs): keys_to_set = ( @@ -134,12 +135,13 @@ class PatchClampSeries(TimeSeries): 'doc': 'Sweep number, allows for grouping different PatchClampSeries ' 'together via the sweep_table', 'default': None, - } + }, + allow_positional=AllowPositional.WARNING, ) def __init__(self, **kwargs): - name, data, unit, stimulus_description = popargs('name', 'data', 'unit', 'stimulus_description', kwargs) - electrode, gain, sweep_number = popargs('electrode', 'gain', 'sweep_number', kwargs) - super().__init__(name, data, unit, **kwargs) + electrode, gain, stimulus_description, sweep_number = popargs('electrode', 'gain', 'stimulus_description', + 'sweep_number', kwargs) + super().__init__(**kwargs) self.electrode = electrode self.gain = gain self.stimulus_description = stimulus_description @@ -172,13 +174,14 @@ class CurrentClampSeries(PatchClampSeries): *get_docval(PatchClampSeries.__init__, 'resolution', 'conversion', 'timestamps', 'starting_time', 'rate', 'comments', 'description', 'control', 'control_description', 'sweep_number', 'offset'), {'name': 'unit', 'type': str, 'doc': "The base unit of measurement (must be 'volts')", - 'default': 'volts'}) + 'default': 'volts'}, + allow_positional=AllowPositional.WARNING,) def __init__(self, **kwargs): - name, data, unit, electrode, gain = popargs('name', 'data', 'unit', 'electrode', 'gain', kwargs) + name, unit = popargs('name', 'unit', kwargs) unit = ensure_unit(self, name, unit, 'volts', '2.1.0') bias_current, bridge_balance, capacitance_compensation = popargs( 'bias_current', 'bridge_balance', 'capacitance_compensation', kwargs) - super().__init__(name, data, unit, electrode, gain, **kwargs) + super().__init__(name=name, unit=unit, **kwargs) self.bias_current = bias_current self.bridge_balance = bridge_balance self.capacitance_compensation = capacitance_compensation @@ -205,14 +208,15 @@ class IZeroClampSeries(CurrentClampSeries): 'starting_time', 'rate', 'comments', 'description', 'control', 'control_description', 'sweep_number', 'offset'), {'name': 'unit', 'type': str, 'doc': "The base unit of measurement (must be 'volts')", - 'default': 'volts'}) + 'default': 'volts'}, + allow_positional=AllowPositional.WARNING,) def __init__(self, **kwargs): - name, data, electrode, gain = popargs('name', 'data', 'electrode', 'gain', kwargs) + name, stimulus_description = popargs('name', 'stimulus_description', kwargs) bias_current, bridge_balance, capacitance_compensation = (0.0, 0.0, 0.0) - stimulus_description = popargs('stimulus_description', kwargs) stimulus_description = self._ensure_stimulus_description(name, stimulus_description, 'N/A', '2.3.0') kwargs['stimulus_description'] = stimulus_description - super().__init__(name, data, electrode, gain, bias_current, bridge_balance, capacitance_compensation, + super().__init__(name=name, bias_current=bias_current, bridge_balance=bridge_balance, + capacitance_compensation=capacitance_compensation, **kwargs) def _ensure_stimulus_description(self, name, current_stim_desc, stim_desc, nwb_version): @@ -243,11 +247,12 @@ class CurrentClampStimulusSeries(PatchClampSeries): 'starting_time', 'rate', 'comments', 'description', 'control', 'control_description', 'sweep_number', 'offset'), {'name': 'unit', 'type': str, 'doc': "The base unit of measurement (must be 'amperes')", - 'default': 'amperes'}) + 'default': 'amperes'}, + allow_positional=AllowPositional.WARNING,) def __init__(self, **kwargs): - name, data, unit, electrode, gain = popargs('name', 'data', 'unit', 'electrode', 'gain', kwargs) + name, unit = popargs('name', 'unit', kwargs) unit = ensure_unit(self, name, unit, 'amperes', '2.1.0') - super().__init__(name, data, unit, electrode, gain, **kwargs) + super().__init__(name=name, unit=unit, **kwargs) @register_class('VoltageClampSeries', CORE_NAMESPACE) @@ -279,16 +284,17 @@ class VoltageClampSeries(PatchClampSeries): *get_docval(PatchClampSeries.__init__, 'resolution', 'conversion', 'timestamps', 'starting_time', 'rate', 'comments', 'description', 'control', 'control_description', 'sweep_number', 'offset'), {'name': 'unit', 'type': str, 'doc': "The base unit of measurement (must be 'amperes')", - 'default': 'amperes'}) + 'default': 'amperes'}, + allow_positional=AllowPositional.WARNING,) def __init__(self, **kwargs): - name, data, unit, electrode, gain = popargs('name', 'data', 'unit', 'electrode', 'gain', kwargs) - unit = ensure_unit(self, name, unit, 'amperes', '2.1.0') - capacitance_fast, capacitance_slow, resistance_comp_bandwidth, resistance_comp_correction, \ + name, unit, capacitance_fast, capacitance_slow, resistance_comp_bandwidth, resistance_comp_correction, \ resistance_comp_prediction, whole_cell_capacitance_comp, whole_cell_series_resistance_comp = popargs( - 'capacitance_fast', 'capacitance_slow', 'resistance_comp_bandwidth', + 'name', 'unit', 'capacitance_fast', 'capacitance_slow', 'resistance_comp_bandwidth', 'resistance_comp_correction', 'resistance_comp_prediction', 'whole_cell_capacitance_comp', 'whole_cell_series_resistance_comp', kwargs) - super().__init__(name, data, unit, electrode, gain, **kwargs) + unit = ensure_unit(self, name, unit, 'amperes', '2.1.0') + + super().__init__(name=name, unit=unit, **kwargs) self.capacitance_fast = capacitance_fast self.capacitance_slow = capacitance_slow self.resistance_comp_bandwidth = resistance_comp_bandwidth @@ -312,11 +318,12 @@ class VoltageClampStimulusSeries(PatchClampSeries): 'starting_time', 'rate', 'comments', 'description', 'control', 'control_description', 'sweep_number', 'offset'), {'name': 'unit', 'type': str, 'doc': "The base unit of measurement (must be 'volts')", - 'default': 'volts'}) + 'default': 'volts'}, + allow_positional=AllowPositional.WARNING,) def __init__(self, **kwargs): - name, data, unit, electrode, gain = popargs('name', 'data', 'unit', 'electrode', 'gain', kwargs) + name, unit = popargs('name', 'unit', kwargs) unit = ensure_unit(self, name, unit, 'volts', '2.1.0') - super().__init__(name, data, unit, electrode, gain, **kwargs) + super().__init__(name=name, unit=unit, **kwargs) @register_class('SweepTable', CORE_NAMESPACE) @@ -394,7 +401,8 @@ class IntracellularElectrodesTable(DynamicTable): 'table': False}, ) - @docval(*get_docval(DynamicTable.__init__, 'id', 'columns', 'colnames')) + @docval(*get_docval(DynamicTable.__init__, 'id', 'columns', 'colnames'), + allow_positional=AllowPositional.WARNING,) def __init__(self, **kwargs): # Define defaultb name and description settings kwargs['name'] = 'electrodes' @@ -423,7 +431,8 @@ class IntracellularStimuliTable(DynamicTable): 'class': TimeSeriesReferenceVectorData}, ) - @docval(*get_docval(DynamicTable.__init__, 'id', 'columns', 'colnames')) + @docval(*get_docval(DynamicTable.__init__, 'id', 'columns', 'colnames'), + allow_positional=AllowPositional.WARNING,) def __init__(self, **kwargs): # Define defaultb name and description settings kwargs['name'] = 'stimuli' @@ -446,7 +455,8 @@ class IntracellularResponsesTable(DynamicTable): 'class': TimeSeriesReferenceVectorData}, ) - @docval(*get_docval(DynamicTable.__init__, 'id', 'columns', 'colnames')) + @docval(*get_docval(DynamicTable.__init__, 'id', 'columns', 'colnames'), + allow_positional=AllowPositional.WARNING,) def __init__(self, **kwargs): # Define defaultb name and description settings kwargs['name'] = 'responses' @@ -462,7 +472,8 @@ class IntracellularRecordingsTable(AlignedDynamicTable): a single simultaneous_recording. Each row in the table represents a single recording consisting typically of a stimulus and a corresponding response. """ - @docval(*get_docval(AlignedDynamicTable.__init__, 'id', 'columns', 'colnames', 'category_tables', 'categories')) + @docval(*get_docval(AlignedDynamicTable.__init__, 'id', 'columns', 'colnames', 'category_tables', 'categories'), + allow_positional=AllowPositional.WARNING,) def __init__(self, **kwargs): kwargs['name'] = 'intracellular_recordings' kwargs['description'] = ('A table to group together a stimulus and response from a single electrode ' @@ -747,7 +758,8 @@ class SimultaneousRecordingsTable(DynamicTable): 'reading the Container from file as the table attribute is already populated in this case ' 'but otherwise this is required.', 'default': None}, - *get_docval(DynamicTable.__init__, 'id', 'columns', 'colnames')) + *get_docval(DynamicTable.__init__, 'id', 'columns', 'colnames'), + allow_positional=AllowPositional.WARNING,) def __init__(self, **kwargs): intracellular_recordings_table = popargs('intracellular_recordings_table', kwargs) # Define default name and description settings @@ -806,7 +818,8 @@ class SequentialRecordingsTable(DynamicTable): 'column indexes. May be None when reading the Container from file as the ' 'table attribute is already populated in this case but otherwise this is required.', 'default': None}, - *get_docval(DynamicTable.__init__, 'id', 'columns', 'colnames')) + *get_docval(DynamicTable.__init__, 'id', 'columns', 'colnames'), + allow_positional=AllowPositional.WARNING,) def __init__(self, **kwargs): simultaneous_recordings_table = popargs('simultaneous_recordings_table', kwargs) # Define defaultb name and description settings @@ -863,7 +876,8 @@ class RepetitionsTable(DynamicTable): 'be None when reading the Container from file as the table attribute is already populated ' 'in this case but otherwise this is required.', 'default': None}, - *get_docval(DynamicTable.__init__, 'id', 'columns', 'colnames')) + *get_docval(DynamicTable.__init__, 'id', 'columns', 'colnames'), + allow_positional=AllowPositional.WARNING,) def __init__(self, **kwargs): sequential_recordings_table = popargs('sequential_recordings_table', kwargs) # Define default name and description settings @@ -915,7 +929,8 @@ class ExperimentalConditionsTable(DynamicTable): 'type': RepetitionsTable, 'doc': 'the RepetitionsTable table that the repetitions column indexes', 'default': None}, - *get_docval(DynamicTable.__init__, 'id', 'columns', 'colnames')) + *get_docval(DynamicTable.__init__, 'id', 'columns', 'colnames'), + allow_positional=AllowPositional.WARNING,) def __init__(self, **kwargs): repetitions_table = popargs('repetitions_table', kwargs) # Define default name and description settings diff --git a/src/pynwb/image.py b/src/pynwb/image.py index 518ec8a8c..e8adf8ed8 100644 --- a/src/pynwb/image.py +++ b/src/pynwb/image.py @@ -10,6 +10,7 @@ popargs_to_dict, get_docval, get_data_shape, + AllowPositional, ) from . import register_class, CORE_NAMESPACE @@ -61,7 +62,8 @@ class ImageSeries(TimeSeries): *get_docval(TimeSeries.__init__, 'resolution', 'conversion', 'timestamps', 'starting_time', 'rate', 'comments', 'description', 'control', 'control_description', 'offset'), {'name': 'device', 'type': Device, - 'doc': 'Device used to capture the images/video.', 'default': None},) + 'doc': 'Device used to capture the images/video.', 'default': None}, + allow_positional=AllowPositional.WARNING,) def __init__(self, **kwargs): keys_to_set = ('bits_per_pixel', 'dimension', 'external_file', 'starting_frame', 'format', 'device') args_to_set = popargs_to_dict(keys_to_set, kwargs) @@ -251,6 +253,7 @@ class IndexSeries(TimeSeries): 'control_description', 'offset', ), + allow_positional=AllowPositional.WARNING, ) def __init__(self, **kwargs): indexed_timeseries, indexed_images = popargs('indexed_timeseries', 'indexed_images', kwargs) @@ -297,7 +300,8 @@ class ImageMaskSeries(ImageSeries): {'name': 'device', 'type': Device, 'doc': ('Device used to capture the mask data. This field will likely not be needed. ' 'The device used to capture the masked ImageSeries data should be stored in the ImageSeries.'), - 'default': None},) + 'default': None}, + allow_positional=AllowPositional.WARNING,) def __init__(self, **kwargs): masked_imageseries = popargs('masked_imageseries', kwargs) super().__init__(**kwargs) @@ -333,7 +337,8 @@ class OpticalSeries(ImageSeries): 'default': None}, *get_docval(ImageSeries.__init__, 'unit', 'format', 'external_file', 'starting_frame', 'bits_per_pixel', 'dimension', 'resolution', 'conversion', 'timestamps', 'starting_time', 'rate', 'comments', - 'description', 'control', 'control_description', 'device', 'offset')) + 'description', 'control', 'control_description', 'device', 'offset'), + allow_positional=AllowPositional.WARNING,) def __init__(self, **kwargs): distance, field_of_view, orientation = popargs('distance', 'field_of_view', 'orientation', kwargs) super().__init__(**kwargs) @@ -349,7 +354,8 @@ class GrayscaleImage(Image): {'name': 'data', 'type': ('array_data', 'data'), 'doc': 'Data of grayscale image. Must be 2D where the dimensions represent x and y.', 'shape': (None, None)}, - *get_docval(Image.__init__, 'resolution', 'description')) + *get_docval(Image.__init__, 'resolution', 'description'), + allow_positional=AllowPositional.WARNING,) def __init__(self, **kwargs): super().__init__(**kwargs) @@ -362,7 +368,8 @@ class RGBImage(Image): 'doc': 'Data of color image. Must be 3D where the first and second dimensions represent x and y. ' 'The third dimension has length 3 and represents the RGB value.', 'shape': (None, None, 3)}, - *get_docval(Image.__init__, 'resolution', 'description')) + *get_docval(Image.__init__, 'resolution', 'description'), + allow_positional=AllowPositional.WARNING,) def __init__(self, **kwargs): super().__init__(**kwargs) @@ -375,6 +382,7 @@ class RGBAImage(Image): 'doc': 'Data of color image with transparency. Must be 3D where the first and second dimensions ' 'represent x and y. The third dimension has length 4 and represents the RGBA value.', 'shape': (None, None, 4)}, - *get_docval(Image.__init__, 'resolution', 'description')) + *get_docval(Image.__init__, 'resolution', 'description'), + allow_positional=AllowPositional.WARNING,) def __init__(self, **kwargs): super().__init__(**kwargs) diff --git a/src/pynwb/misc.py b/src/pynwb/misc.py index 14c2e08d1..118f2c444 100644 --- a/src/pynwb/misc.py +++ b/src/pynwb/misc.py @@ -4,7 +4,7 @@ import numpy as np -from hdmf.utils import docval, getargs, popargs, popargs_to_dict, get_docval +from hdmf.utils import docval, getargs, popargs, popargs_to_dict, get_docval, AllowPositional from . import register_class, CORE_NAMESPACE from .base import TimeSeries @@ -25,7 +25,8 @@ class AnnotationSeries(TimeSeries): {'name': 'data', 'type': ('array_data', 'data', TimeSeries), 'shape': (None,), 'doc': 'The annotations over time. Must be 1D.', 'default': list()}, - *get_docval(TimeSeries.__init__, 'timestamps', 'comments', 'description')) + *get_docval(TimeSeries.__init__, 'timestamps', 'comments', 'description'), + allow_positional=AllowPositional.WARNING,) def __init__(self, **kwargs): name, data, timestamps = popargs('name', 'data', 'timestamps', kwargs) super().__init__(name=name, data=data, unit='n/a', resolution=-1.0, timestamps=timestamps, **kwargs) @@ -63,7 +64,8 @@ class AbstractFeatureSeries(TimeSeries): 'dimension represents features'), 'default': list()}, *get_docval(TimeSeries.__init__, 'resolution', 'conversion', 'timestamps', 'starting_time', 'rate', - 'comments', 'description', 'control', 'control_description', 'offset')) + 'comments', 'description', 'control', 'control_description', 'offset'), + allow_positional=AllowPositional.WARNING,) def __init__(self, **kwargs): name, data, features, feature_units = popargs('name', 'data', 'features', 'feature_units', kwargs) @@ -100,7 +102,8 @@ class IntervalSeries(TimeSeries): 'doc': ('The data values. Must be 1D, where the first dimension must be time. Values are >0 if ' 'interval started, <0 if interval ended.'), 'default': list()}, - *get_docval(TimeSeries.__init__, 'timestamps', 'comments', 'description', 'control', 'control_description')) + *get_docval(TimeSeries.__init__, 'timestamps', 'comments', 'description', 'control', 'control_description'), + allow_positional=AllowPositional.WARNING,) def __init__(self, **kwargs): name, data, timestamps = popargs('name', 'data', 'timestamps', kwargs) self.__interval_timestamps = timestamps @@ -164,7 +167,8 @@ class Units(DynamicTable): {'name': 'waveform_unit', 'type': str, 'doc': 'Unit of measurement of the waveform means', 'default': 'volts'}, {'name': 'resolution', 'type': float, - 'doc': 'The smallest possible difference between two spike times', 'default': None} + 'doc': 'The smallest possible difference between two spike times', 'default': None}, + allow_positional=AllowPositional.WARNING, ) def __init__(self, **kwargs): args_to_set = popargs_to_dict(("waveform_rate", "waveform_unit", "resolution"), kwargs) @@ -198,7 +202,7 @@ def __init__(self, **kwargs): {'name': 'waveforms', 'type': 'array_data', 'default': None, 'doc': waveforms_desc, 'shape': ((None, None), (None, None, None))}, {'name': 'id', 'type': int, 'default': None, 'doc': 'the id for each unit'}, - allow_extra=True) + allow_extra=True,) def add_unit(self, **kwargs): """ Add a unit to this table @@ -277,7 +281,8 @@ class DecompositionSeries(TimeSeries): 'similar to ElectricalSeries.electrodes.'), 'default': None}, *get_docval(TimeSeries.__init__, 'resolution', 'conversion', 'timestamps', 'starting_time', 'rate', - 'comments', 'control', 'control_description', 'offset')) + 'comments', 'control', 'control_description', 'offset'), + allow_positional=AllowPositional.WARNING,) def __init__(self, **kwargs): metric, source_timeseries, bands, source_channels = popargs('metric', 'source_timeseries', 'bands', 'source_channels', kwargs) diff --git a/src/pynwb/ogen.py b/src/pynwb/ogen.py index af11842e4..a1370b4b0 100644 --- a/src/pynwb/ogen.py +++ b/src/pynwb/ogen.py @@ -1,4 +1,4 @@ -from hdmf.utils import docval, popargs, get_docval, popargs_to_dict +from hdmf.utils import docval, popargs, get_docval, popargs_to_dict, AllowPositional from . import register_class, CORE_NAMESPACE from .base import TimeSeries @@ -19,7 +19,8 @@ class OptogeneticStimulusSite(NWBContainer): {'name': 'device', 'type': Device, 'doc': 'The device that was used.'}, {'name': 'description', 'type': str, 'doc': 'Description of site.'}, {'name': 'excitation_lambda', 'type': float, 'doc': 'Excitation wavelength in nm.'}, - {'name': 'location', 'type': str, 'doc': 'Location of stimulation site.'}) + {'name': 'location', 'type': str, 'doc': 'Location of stimulation site.'}, + allow_positional=AllowPositional.WARNING,) def __init__(self, **kwargs): args_to_set = popargs_to_dict(('device', 'description', 'excitation_lambda', 'location'), kwargs) super().__init__(**kwargs) @@ -43,7 +44,8 @@ class OptogeneticSeries(TimeSeries): {'name': 'site', 'type': OptogeneticStimulusSite, # required 'doc': 'The site to which this stimulus was applied.'}, *get_docval(TimeSeries.__init__, 'resolution', 'conversion', 'timestamps', 'starting_time', 'rate', - 'comments', 'description', 'control', 'control_description', 'offset')) + 'comments', 'description', 'control', 'control_description', 'offset'), + allow_positional=AllowPositional.WARNING,) def __init__(self, **kwargs): site = popargs('site', kwargs) kwargs['unit'] = 'watts' diff --git a/src/pynwb/ophys.py b/src/pynwb/ophys.py index 6f1483079..aecba765d 100644 --- a/src/pynwb/ophys.py +++ b/src/pynwb/ophys.py @@ -3,7 +3,7 @@ import warnings from hdmf.common import DynamicTable, DynamicTableRegion -from hdmf.utils import docval, popargs, get_docval, get_data_shape, popargs_to_dict +from hdmf.utils import docval, popargs, get_docval, get_data_shape, popargs_to_dict, AllowPositional from . import register_class, CORE_NAMESPACE from .base import TimeSeries @@ -21,7 +21,8 @@ class OpticalChannel(NWBContainer): @docval({'name': 'name', 'type': str, 'doc': 'the name of this electrode'}, # required {'name': 'description', 'type': str, 'doc': 'Any notes or comments about the channel.'}, # required - {'name': 'emission_lambda', 'type': float, 'doc': 'Emission wavelength for channel, in nm.'}) # required + {'name': 'emission_lambda', 'type': float, 'doc': 'Emission wavelength for channel, in nm.'}, # required + allow_positional=AllowPositional.WARNING,) def __init__(self, **kwargs): description, emission_lambda = popargs("description", "emission_lambda", kwargs) super().__init__(**kwargs) @@ -90,7 +91,8 @@ class ImagingPlane(NWBContainer): 'default': None}, {'name': 'grid_spacing_unit', 'type': str, 'doc': "Measurement units for grid_spacing. The default value is 'meters'.", - 'default': 'meters'}) + 'default': 'meters'}, + allow_positional=AllowPositional.WARNING,) def __init__(self, **kwargs): keys_to_set = ('optical_channel', 'description', @@ -188,7 +190,8 @@ class OnePhotonSeries(ImageSeries): "control_description", "device", "offset", - ) + ), + allow_positional=AllowPositional.WARNING, ) def __init__(self, **kwargs): keys_to_set = ( @@ -227,7 +230,8 @@ class TwoPhotonSeries(ImageSeries): 'default': None}, *get_docval(ImageSeries.__init__, 'external_file', 'starting_frame', 'bits_per_pixel', 'dimension', 'resolution', 'conversion', 'timestamps', 'starting_time', 'rate', - 'comments', 'description', 'control', 'control_description', 'device', 'offset')) + 'comments', 'description', 'control', 'control_description', 'device', 'offset'), + allow_positional=AllowPositional.WARNING,) def __init__(self, **kwargs): keys_to_set = ("field_of_view", "imaging_plane", @@ -260,7 +264,8 @@ class CorrectedImageStack(NWBDataInterface): 'doc': 'Link to image series that is being registered.'}, {'name': 'xy_translation', 'type': TimeSeries, 'doc': 'Stores the x,y delta necessary to align each frame to the common coordinates, ' - 'for example, to align each frame to a reference image. This must have the name "xy_translation".'}) + 'for example, to align each frame to a reference image. This must have the name "xy_translation".'}, + allow_positional=AllowPositional.WARNING,) def __init__(self, **kwargs): corrected, original, xy_translation = popargs('corrected', 'original', 'xy_translation', kwargs) super().__init__(**kwargs) @@ -312,7 +317,8 @@ class PlaneSegmentation(DynamicTable): {'name': 'name', 'type': str, 'doc': 'name of PlaneSegmentation.', 'default': None}, {'name': 'reference_images', 'type': (ImageSeries, list, dict, tuple), 'default': None, 'doc': 'One or more image stacks that the masks apply to (can be oneelement stack).'}, - *get_docval(DynamicTable.__init__, 'id', 'columns', 'colnames')) + *get_docval(DynamicTable.__init__, 'id', 'columns', 'colnames'), + allow_positional=AllowPositional.WARNING,) def __init__(self, **kwargs): imaging_plane, reference_images = popargs('imaging_plane', 'reference_images', kwargs) if kwargs['name'] is None: @@ -425,7 +431,8 @@ class RoiResponseSeries(TimeSeries): {'name': 'rois', 'type': DynamicTableRegion, # required 'doc': 'a table region corresponding to the ROIs that were used to generate this data'}, *get_docval(TimeSeries.__init__, 'resolution', 'conversion', 'timestamps', 'starting_time', 'rate', - 'comments', 'description', 'control', 'control_description', 'offset')) + 'comments', 'description', 'control', 'control_description', 'offset'), + allow_positional=AllowPositional.WARNING,) def __init__(self, **kwargs): rois = popargs('rois', kwargs) diff --git a/src/pynwb/resources.py b/src/pynwb/resources.py index acdc22b12..1158922bb 100644 --- a/src/pynwb/resources.py +++ b/src/pynwb/resources.py @@ -1,6 +1,6 @@ from hdmf.common import HERD as hdmf_HERD from . import get_type_map as tm -from hdmf.utils import docval, get_docval +from hdmf.utils import docval, get_docval, AllowPositional class HERD(hdmf_HERD): @@ -8,7 +8,8 @@ class HERD(hdmf_HERD): HDMF External Resources Data Structure. A table for mapping user terms (i.e. keys) to resource entities. """ - @docval(*get_docval(hdmf_HERD.__init__)) + @docval(*get_docval(hdmf_HERD.__init__), + allow_positional=AllowPositional.WARNING,) def __init__(self, **kwargs): kwargs['type_map'] = tm() super().__init__(**kwargs) diff --git a/tests/integration/hdf5/test_image.py b/tests/integration/hdf5/test_image.py index 4cc731d41..178d92a05 100644 --- a/tests/integration/hdf5/test_image.py +++ b/tests/integration/hdf5/test_image.py @@ -9,7 +9,7 @@ class TestImageSeriesIO(AcquisitionH5IOMixin, TestCase): def setUpContainer(self): """ Return a test ImageSeries to read/write """ - self.dev1 = Device('dev1') + self.dev1 = Device(name='dev1') iS = ImageSeries( name='test_iS', unit='unit', @@ -31,7 +31,7 @@ class TestOpticalSeriesIO(NWBH5IOMixin, TestCase): def setUpContainer(self): """ Return a test OpticalSeries to read/write """ - self.dev1 = Device('dev1') + self.dev1 = Device(name='dev1') self.optical_series = OpticalSeries( name='OpticalSeries', distance=8., diff --git a/tests/integration/hdf5/test_misc.py b/tests/integration/hdf5/test_misc.py index cd9ab1706..fe0ded502 100644 --- a/tests/integration/hdf5/test_misc.py +++ b/tests/integration/hdf5/test_misc.py @@ -75,7 +75,7 @@ class TestUnitsFileIO(NWBH5IOMixin, TestCase): def setUpContainer(self): """ Return placeholder Units object. Tested units are added directly to the NWBFile in addContainer """ - return Units('placeholder') # this will get ignored + return Units(name='placeholder') # this will get ignored def addContainer(self, nwbfile): """ Add units to the given NWBFile """ diff --git a/tests/integration/hdf5/test_nwbfile.py b/tests/integration/hdf5/test_nwbfile.py index e164ec649..a9de78e5f 100644 --- a/tests/integration/hdf5/test_nwbfile.py +++ b/tests/integration/hdf5/test_nwbfile.py @@ -261,7 +261,7 @@ class TestEpochsIO(NWBH5IOMixin, TestCase): def setUpContainer(self): """ Return placeholder epochs object. Tested epochs are added directly to the NWBFile in addContainer """ - return TimeIntervals('epochs') + return TimeIntervals(name='epochs') def addContainer(self, nwbfile): """ Add the test epochs to the given NWBFile """ diff --git a/tests/unit/test_ecephys.py b/tests/unit/test_ecephys.py index 1415c3d30..68e1e349f 100644 --- a/tests/unit/test_ecephys.py +++ b/tests/unit/test_ecephys.py @@ -25,8 +25,11 @@ def make_electrode_table(): table = ElectrodeTable() - dev1 = Device('dev1') - group = ElectrodeGroup('tetrode1', 'tetrode description', 'tetrode location', dev1) + dev1 = Device(name='dev1') + group = ElectrodeGroup(name='tetrode1', + description='tetrode description', + location='tetrode location', + device=dev1) table.add_row(location='CA1', group=group, group_name='tetrode1') table.add_row(location='CA1', group=group, group_name='tetrode1') table.add_row(location='CA1', group=group, group_name='tetrode1') @@ -70,9 +73,10 @@ def test_init(self): def test_link(self): table, region = self._create_table_and_region() - ts1 = ElectricalSeries('test_ts1', [0, 1, 2, 3, 4, 5], region, timestamps=[0.0, 0.1, 0.2, 0.3, 0.4, 0.5]) - ts2 = ElectricalSeries('test_ts2', ts1, region, timestamps=ts1) - ts3 = ElectricalSeries('test_ts3', ts2, region, timestamps=ts2) + ts1 = ElectricalSeries(name='test_ts1', data=[0, 1, 2, 3, 4, 5], electrodes=region, + timestamps=[0.0, 0.1, 0.2, 0.3, 0.4, 0.5]) + ts2 = ElectricalSeries(name='test_ts2', data=ts1, electrodes=region, timestamps=ts1) + ts3 = ElectricalSeries(name='test_ts3', data=ts2, electrodes=region, timestamps=ts2) self.assertEqual(ts2.data, [0, 1, 2, 3, 4, 5]) self.assertEqual(ts2.timestamps, [0.0, 0.1, 0.2, 0.3, 0.4, 0.5]) self.assertEqual(ts3.data, [0, 1, 2, 3, 4, 5]) @@ -82,7 +86,8 @@ def test_invalid_data_shape(self): table, region = self._create_table_and_region() with self.assertRaisesWith(ValueError, ("ElectricalSeries.__init__: incorrect shape for 'data' (got '(2, 2, 2, " "2)', expected '((None,), (None, None), (None, None, None))')")): - ElectricalSeries('test_ts1', np.ones((2, 2, 2, 2)), region, timestamps=[0.0, 0.1, 0.2, 0.3, 0.4, 0.5]) + ElectricalSeries(name='test_ts1', data=np.ones((2, 2, 2, 2)), electrodes=region, + timestamps=[0.0, 0.1, 0.2, 0.3, 0.4, 0.5]) def test_dimensions_warning(self): table, region = self._create_table_and_region() @@ -177,7 +182,7 @@ def test_incorrect_timestamps(self): class ElectrodeGroupConstructor(TestCase): def test_init(self): - dev1 = Device('dev1') + dev1 = Device(name='dev1') group = ElectrodeGroup(name='elec1', description='electrode description', location='electrode location', @@ -191,9 +196,12 @@ def test_init(self): def test_init_position_array(self): position = np.array((1, 2, 3), dtype=np.dtype([('x', float), ('y', float), ('z', float)])) - dev1 = Device('dev1') - group = ElectrodeGroup('elec1', 'electrode description', 'electrode location', dev1, - position) + dev1 = Device(name='dev1') + group = ElectrodeGroup(name='elec1', + description='electrode description', + location='electrode location', + device=dev1, + position=position) self.assertEqual(group.name, 'elec1') self.assertEqual(group.description, 'electrode description') self.assertEqual(group.location, 'electrode location') @@ -201,7 +209,7 @@ def test_init_position_array(self): self.assertEqual(group.position, position) def test_init_position_none(self): - dev1 = Device('dev1') + dev1 = Device(name='dev1') group = ElectrodeGroup(name='elec1', description='electrode description', location='electrode location', @@ -213,7 +221,7 @@ def test_init_position_none(self): self.assertIsNone(group.position) def test_init_position_bad(self): - dev1 = Device('dev1') + dev1 = Device(name='dev1') with self.assertRaises(ValueError): ElectrodeGroup(name='elec1', description='electrode description', @@ -256,8 +264,11 @@ def test_init(self): data = list(range(10)) ts = [0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0] table, region = self._create_table_and_region() - eS = ElectricalSeries('test_eS', data, region, timestamps=ts) - eD = EventDetection('detection_method', eS, (1, 2, 3), (0.1, 0.2, 0.3)) + eS = ElectricalSeries(name='test_eS', data=data, electrodes=region, timestamps=ts) + eD = EventDetection(detection_method='detection_method', + source_electricalseries=eS, + source_idx=(1, 2, 3), + times=(0.1, 0.2, 0.3)) self.assertEqual(eD.detection_method, 'detection_method') self.assertEqual(eD.source_electricalseries, eS) self.assertEqual(eD.source_idx, (1, 2, 3)) @@ -279,7 +290,10 @@ def _create_table_and_region(self): def test_init(self): table, region = self._create_table_and_region() - sES = SpikeEventSeries('test_sES', list(range(10)), list(range(10)), region) + sES = SpikeEventSeries(name='test_sES', + data=list(range(10)), + timestamps=list(range(10)), + electrodes=region) pm = ProcessingModule(name='test_module', description='a test module') ew = EventWaveform() @@ -344,7 +358,8 @@ def _create_table_and_region(self): def test_init(self): _, region = self._create_table_and_region() - eS = ElectricalSeries('test_eS', [0, 1, 2, 3], region, timestamps=[0.1, 0.2, 0.3, 0.4]) + eS = ElectricalSeries(name='test_eS', data=[0, 1, 2, 3], + electrodes=region, timestamps=[0.1, 0.2, 0.3, 0.4]) msg = ( "The linked table for DynamicTableRegion 'electrodes' does not share " "an ancestor with the DynamicTableRegion." @@ -357,7 +372,10 @@ def test_init(self): def test_add_electrical_series(self): lfp = LFP() table, region = self._create_table_and_region() - eS = ElectricalSeries('test_eS', [0, 1, 2, 3], region, timestamps=[0.1, 0.2, 0.3, 0.4]) + eS = ElectricalSeries(name='test_eS', + data=[0, 1, 2, 3], + electrodes=region, + timestamps=[0.1, 0.2, 0.3, 0.4]) pm = ProcessingModule(name='test_module', description='a test module') pm.add(table) pm.add(lfp) @@ -379,7 +397,10 @@ def _create_table_and_region(self): def test_init(self): _, region = self._create_table_and_region() - eS = ElectricalSeries('test_eS', [0, 1, 2, 3], region, timestamps=[0.1, 0.2, 0.3, 0.4]) + eS = ElectricalSeries(name='test_eS', + data=[0, 1, 2, 3], + electrodes=region, + timestamps=[0.1, 0.2, 0.3, 0.4]) msg = ( "The linked table for DynamicTableRegion 'electrodes' does not share " "an ancestor with the DynamicTableRegion." @@ -391,7 +412,10 @@ def test_init(self): def test_add_electrical_series(self): table, region = self._create_table_and_region() - eS = ElectricalSeries('test_eS', [0, 1, 2, 3], region, timestamps=[0.1, 0.2, 0.3, 0.4]) + eS = ElectricalSeries(name='test_eS', + data=[0, 1, 2, 3], + electrodes=region, + timestamps=[0.1, 0.2, 0.3, 0.4]) pm = ProcessingModule(name='test_module', description='a test module') fe = FilteredEphys() pm.add(table) @@ -418,7 +442,10 @@ def test_init(self): table, region = self._create_table_and_region() description = ['desc1', 'desc2', 'desc3'] features = [[[0, 1, 2], [3, 4, 5]], [[6, 7, 8], [9, 10, 11]]] - fe = FeatureExtraction(region, description, event_times, features) + fe = FeatureExtraction(electrodes=region, + description=description, + times=event_times, + features=features) self.assertEqual(fe.description, description) self.assertEqual(fe.times, event_times) self.assertEqual(fe.features, features) @@ -428,7 +455,11 @@ def test_invalid_init_mismatched_event_times(self): table, region = self._create_table_and_region() description = ['desc1', 'desc2', 'desc3'] features = [[[0, 1, 2], [3, 4, 5]]] - self.assertRaises(ValueError, FeatureExtraction, region, description, event_times, features) + with self.assertRaises(ValueError): + FeatureExtraction(electrodes=region, + description=description, + times=event_times, + features=features) def test_invalid_init_mismatched_electrodes(self): event_times = [1] @@ -436,18 +467,30 @@ def test_invalid_init_mismatched_electrodes(self): region = DynamicTableRegion(name='electrodes', data=[0], description='the first electrode', table=table) description = ['desc1', 'desc2', 'desc3'] features = [[[0, 1, 2], [3, 4, 5]]] - self.assertRaises(ValueError, FeatureExtraction, region, description, event_times, features) + with self.assertRaises(ValueError): + FeatureExtraction(electrodes=region, + description=description, + times=event_times, + features=features) def test_invalid_init_mismatched_description(self): event_times = [1] table, region = self._create_table_and_region() description = ['desc1', 'desc2', 'desc3', 'desc4'] # Need 3 descriptions but give 4 features = [[[0, 1, 2], [3, 4, 5]]] - self.assertRaises(ValueError, FeatureExtraction, region, description, event_times, features) + with self.assertRaises(ValueError): + FeatureExtraction(electrodes=region, + description=description, + times=event_times, + features=features) def test_invalid_init_mismatched_description2(self): event_times = [1] table, region = self._create_table_and_region() description = ['desc1', 'desc2', 'desc3'] features = [[0, 1, 2], [3, 4, 5]] # Need 3D feature array but give only 2D array - self.assertRaises(ValueError, FeatureExtraction, region, description, event_times, features) + with self.assertRaises(ValueError): + FeatureExtraction(electrodes=region, + description=description, + times=event_times, + features=features) diff --git a/tests/unit/test_epoch_legacy.py b/tests/unit/test_epoch_legacy.py index 1f6c50f38..eebc35198 100644 --- a/tests/unit/test_epoch_legacy.py +++ b/tests/unit/test_epoch_legacy.py @@ -21,7 +21,7 @@ class TestTimeIntervalsIO(NWBH5IOMixin, TestCase): def setUpContainer(self): """ Return placeholder epochs object. Tested epochs are added directly to the NWBFile in addContainer """ - return TimeIntervals('epochs') + return TimeIntervals(name='epochs') def addContainer(self, nwbfile): """ Add the test epochs to the given NWBFile """ @@ -62,7 +62,8 @@ def getContainer(self, nwbfile): def test_legacy_format(self): description = 'a file to test writing and reading a %s' % self.container_type identifier = 'TEST_%s' % self.container_type - nwbfile = NWBFile(description, identifier, self.start_time, file_create_date=self.create_date) + nwbfile = NWBFile(session_description=description, identifier=identifier, + session_start_time=self.start_time, file_create_date=self.create_date) self.addContainer(nwbfile) # write the file diff --git a/tests/unit/test_file.py b/tests/unit/test_file.py index 8cb3415d9..aba85a355 100644 --- a/tests/unit/test_file.py +++ b/tests/unit/test_file.py @@ -135,7 +135,10 @@ def test_epoch_tags(self): tags1 = ['t1', 't2'] tags2 = ['t3', 't4'] tstamps = np.arange(1.0, 100.0, 0.1, dtype=np.float64) - ts = TimeSeries("test_ts", list(range(len(tstamps))), 'unit', timestamps=tstamps) + ts = TimeSeries(name="test_ts", + data=list(range(len(tstamps))), + unit='unit', + timestamps=tstamps) expected_tags = tags1 + tags2 self.nwbfile.add_epoch(0.0, 1.0, tags1, ts) self.nwbfile.add_epoch(0.0, 1.0, tags2, ts) @@ -155,13 +158,17 @@ def test_epoch_tags_no_table(self): self.assertEqual(set(), self.nwbfile.epoch_tags) def test_add_acquisition(self): - self.nwbfile.add_acquisition(TimeSeries('test_ts', [0, 1, 2, 3, 4, 5], - 'grams', timestamps=[0.0, 0.1, 0.2, 0.3, 0.4, 0.5])) + self.nwbfile.add_acquisition(TimeSeries(name='test_ts', + data=[0, 1, 2, 3, 4, 5], + unit='grams', + timestamps=[0.0, 0.1, 0.2, 0.3, 0.4, 0.5])) self.assertEqual(len(self.nwbfile.acquisition), 1) def test_add_stimulus(self): - self.nwbfile.add_stimulus(TimeSeries('test_ts', [0, 1, 2, 3, 4, 5], - 'grams', timestamps=[0.0, 0.1, 0.2, 0.3, 0.4, 0.5])) + self.nwbfile.add_stimulus(TimeSeries(name='test_ts', + data=[0, 1, 2, 3, 4, 5], + unit='grams', + timestamps=[0.0, 0.1, 0.2, 0.3, 0.4, 0.5])) self.assertEqual(len(self.nwbfile.stimulus), 1) def test_add_stimulus_timeseries_arg(self): @@ -202,8 +209,10 @@ def test_add_stimulus_dynamic_table(self): self.assertIs(self.nwbfile.stimulus['test_dynamic_table'], dt) def test_add_stimulus_template(self): - self.nwbfile.add_stimulus_template(TimeSeries('test_ts', [0, 1, 2, 3, 4, 5], - 'grams', timestamps=[0.0, 0.1, 0.2, 0.3, 0.4, 0.5])) + self.nwbfile.add_stimulus_template(TimeSeries(name='test_ts', + data=[0, 1, 2, 3, 4, 5], + unit='grams', + timestamps=[0.0, 0.1, 0.2, 0.3, 0.4, 0.5])) self.assertEqual(len(self.nwbfile.stimulus_template), 1) def test_add_stimulus_template_images(self): @@ -213,33 +222,45 @@ def test_add_stimulus_template_images(self): self.assertEqual(len(self.nwbfile.stimulus_template), 1) def test_add_analysis(self): - self.nwbfile.add_analysis(TimeSeries('test_ts', [0, 1, 2, 3, 4, 5], - 'grams', timestamps=[0.0, 0.1, 0.2, 0.3, 0.4, 0.5])) + self.nwbfile.add_analysis(TimeSeries(name='test_ts', + data=[0, 1, 2, 3, 4, 5], + unit='grams', + timestamps=[0.0, 0.1, 0.2, 0.3, 0.4, 0.5])) self.assertEqual(len(self.nwbfile.analysis), 1) def test_add_acquisition_check_dups(self): - self.nwbfile.add_acquisition(TimeSeries('test_ts', [0, 1, 2, 3, 4, 5], - 'grams', timestamps=[0.0, 0.1, 0.2, 0.3, 0.4, 0.5])) + self.nwbfile.add_acquisition(TimeSeries(name='test_ts', + data=[0, 1, 2, 3, 4, 5], + unit='grams', + timestamps=[0.0, 0.1, 0.2, 0.3, 0.4, 0.5])) with self.assertRaises(ValueError): - self.nwbfile.add_acquisition(TimeSeries('test_ts', [0, 1, 2, 3, 4, 5], - 'grams', timestamps=[0.0, 0.1, 0.2, 0.3, 0.4, 0.5])) + self.nwbfile.add_acquisition(TimeSeries(name='test_ts', + data=[0, 1, 2, 3, 4, 5], + unit='grams', + timestamps=[0.0, 0.1, 0.2, 0.3, 0.4, 0.5])) def test_get_acquisition_empty(self): with self.assertRaisesWith(ValueError, "acquisition of NWBFile 'root' is empty."): self.nwbfile.get_acquisition() def test_get_acquisition_multiple_elements(self): - self.nwbfile.add_acquisition(TimeSeries('test_ts1', [0, 1, 2, 3, 4, 5], - 'grams', timestamps=[0.0, 0.1, 0.2, 0.3, 0.4, 0.5])) - self.nwbfile.add_acquisition(TimeSeries('test_ts2', [0, 1, 2, 3, 4, 5], - 'grams', timestamps=[0.0, 0.1, 0.2, 0.3, 0.4, 0.5])) + self.nwbfile.add_acquisition(TimeSeries(name='test_ts1', + data=[0, 1, 2, 3, 4, 5], + unit='grams', + timestamps=[0.0, 0.1, 0.2, 0.3, 0.4, 0.5])) + self.nwbfile.add_acquisition(TimeSeries(name='test_ts2', + data=[0, 1, 2, 3, 4, 5], + unit='grams', + timestamps=[0.0, 0.1, 0.2, 0.3, 0.4, 0.5])) msg = "More than one element in acquisition of NWBFile 'root' -- must specify a name." with self.assertRaisesWith(ValueError, msg): self.nwbfile.get_acquisition() def test_add_acquisition_invalid_name(self): - self.nwbfile.add_acquisition(TimeSeries('test_ts', [0, 1, 2, 3, 4, 5], - 'grams', timestamps=[0.0, 0.1, 0.2, 0.3, 0.4, 0.5])) + self.nwbfile.add_acquisition(TimeSeries(name='test_ts', + data=[0, 1, 2, 3, 4, 5], + unit='grams', + timestamps=[0.0, 0.1, 0.2, 0.3, 0.4, 0.5])) msg = "\"'TEST_TS' not found in acquisition of NWBFile 'root'.\"" with self.assertRaisesWith(KeyError, msg): self.nwbfile.get_acquisition("TEST_TS") @@ -406,8 +427,10 @@ def test_add_electrode_missing_group(self): nwbfile.add_electrode(location='a', id=0) def test_all_children(self): - ts1 = TimeSeries('test_ts1', [0, 1, 2, 3, 4, 5], 'grams', timestamps=[0.0, 0.1, 0.2, 0.3, 0.4, 0.5]) - ts2 = TimeSeries('test_ts2', [0, 1, 2, 3, 4, 5], 'grams', timestamps=[0.0, 0.1, 0.2, 0.3, 0.4, 0.5]) + ts1 = TimeSeries(name='test_ts1', data=[0, 1, 2, 3, 4, 5], unit='grams', + timestamps=[0.0, 0.1, 0.2, 0.3, 0.4, 0.5]) + ts2 = TimeSeries(name='test_ts2', data=[0, 1, 2, 3, 4, 5], unit='grams', + timestamps=[0.0, 0.1, 0.2, 0.3, 0.4, 0.5]) self.nwbfile.add_acquisition(ts1) self.nwbfile.add_acquisition(ts2) name = 'example_electrode_group' @@ -429,8 +452,10 @@ def test_fail_if_source_script_file_name_without_source_script(self): source_script_file_name='nofilename') def test_get_neurodata_type(self): - ts1 = TimeSeries('test_ts1', [0, 1, 2, 3, 4, 5], 'grams', timestamps=[0.0, 0.1, 0.2, 0.3, 0.4, 0.5]) - ts2 = TimeSeries('test_ts2', [0, 1, 2, 3, 4, 5], 'grams', timestamps=[0.0, 0.1, 0.2, 0.3, 0.4, 0.5]) + ts1 = TimeSeries(name='test_ts1', data=[0, 1, 2, 3, 4, 5], unit='grams', + timestamps=[0.0, 0.1, 0.2, 0.3, 0.4, 0.5]) + ts2 = TimeSeries(name='test_ts2', data=[0, 1, 2, 3, 4, 5], unit='grams', + timestamps=[0.0, 0.1, 0.2, 0.3, 0.4, 0.5]) self.nwbfile.add_acquisition(ts1) self.nwbfile.add_acquisition(ts2) p1 = ts1.get_ancestor(neurodata_type='NWBFile') @@ -462,8 +487,9 @@ def test_copy(self): self.nwbfile.add_electrode(x=2.0, location='b', group=elecgrp) elec_region = self.nwbfile.create_electrode_table_region([1], 'name') - ts1 = TimeSeries('test_ts1', [0, 1, 2, 3, 4, 5], 'grams', timestamps=[0.0, 0.1, 0.2, 0.3, 0.4, 0.5]) - ts2 = ElectricalSeries('test_ts2', [0, 1, 2, 3, 4, 5], + ts1 = TimeSeries(name='test_ts1', data=[0, 1, 2, 3, 4, 5], unit='grams', + timestamps=[0.0, 0.1, 0.2, 0.3, 0.4, 0.5]) + ts2 = ElectricalSeries(name='test_ts2', data=[0, 1, 2, 3, 4, 5], electrodes=elec_region, timestamps=[0.0, 0.1, 0.2, 0.3, 0.4, 0.5]) self.nwbfile.add_acquisition(ts1) self.nwbfile.add_acquisition(ts2) diff --git a/tests/unit/test_icephys.py b/tests/unit/test_icephys.py index e0e8332f9..3a9db9e61 100644 --- a/tests/unit/test_icephys.py +++ b/tests/unit/test_icephys.py @@ -120,16 +120,16 @@ class IntracellularElectrodeConstructor(TestCase): def test_constructor(self): device = Device(name='device_name') - elec = IntracellularElectrode('test_iS', - device, - 'description', - 'slice', - 'seal', - 'location', - 'resistance', - 'filtering', - 'initial_access_resistance', - 'this_cell') + elec = IntracellularElectrode(name='test_iS', + device=device, + description='description', + slice='slice', + seal='seal', + location='location', + resistance='resistance', + filtering='filtering', + initial_access_resistance='initial_access_resistance', + cell_id='this_cell') self.assertEqual(elec.name, 'test_iS') self.assertEqual(elec.device, device) self.assertEqual(elec.description, 'description') @@ -147,8 +147,12 @@ class PatchClampSeriesConstructor(TestCase): def test_default(self): electrode_name = GetElectrode() - pCS = PatchClampSeries('test_pCS', list(), 'unit', - electrode_name, 1.0, timestamps=list()) + pCS = PatchClampSeries(name='test_pCS', + data=list(), + unit='unit', + electrode=electrode_name, + gain=1.0, + timestamps=list()) self.assertEqual(pCS.name, 'test_pCS') self.assertEqual(pCS.unit, 'unit') self.assertEqual(pCS.electrode, electrode_name) @@ -157,8 +161,13 @@ def test_default(self): def test_sweepNumber_valid(self): electrode_name = GetElectrode() - pCS = PatchClampSeries('test_pCS', list(), 'unit', - electrode_name, 1.0, timestamps=list(), sweep_number=4711) + pCS = PatchClampSeries(name='test_pCS', + data=list(), + unit='unit', + electrode=electrode_name, + gain=1.0, + timestamps=list(), + sweep_number=4711) self.assertEqual(pCS.name, 'test_pCS') self.assertEqual(pCS.unit, 'unit') self.assertEqual(pCS.electrode, electrode_name) @@ -168,8 +177,13 @@ def test_sweepNumber_valid(self): def test_sweepNumber_valid_np(self): electrode_name = GetElectrode() - pCS = PatchClampSeries('test_pCS', list(), 'unit', - electrode_name, 1.0, timestamps=list(), sweep_number=1) + pCS = PatchClampSeries(name='test_pCS', + data=list(), + unit='unit', + electrode=electrode_name, + gain=1.0, + timestamps=list(), + sweep_number=1) self.assertEqual(pCS.name, 'test_pCS') self.assertEqual(pCS.unit, 'unit') self.assertEqual(pCS.electrode, electrode_name) @@ -179,8 +193,13 @@ def test_sweepNumber_valid_np(self): def test_sweepNumber_large_and_valid(self): electrode_name = GetElectrode() - pCS = PatchClampSeries('test_pCS', list(), 'unit', - electrode_name, 1.0, timestamps=list(), sweep_number=np.uint64(2**63-1)) + pCS = PatchClampSeries(name='test_pCS', + data=list(), + unit='unit', + electrode=electrode_name, + gain=1.0, + timestamps=list(), + sweep_number=np.uint64(2**63-1)) self.assertEqual(pCS.name, 'test_pCS') self.assertEqual(pCS.unit, 'unit') self.assertEqual(pCS.electrode, electrode_name) @@ -191,22 +210,37 @@ def test_sweepNumber_throws_with_negative(self): electrode_name = GetElectrode() with self.assertRaises(ValueError): - PatchClampSeries('test_pCS', list(), 'unit', - electrode_name, 1.0, timestamps=list(), sweep_number=-1) + PatchClampSeries(name='test_pCS', + data=list(), + unit='unit', + electrode=electrode_name, + gain=1.0, + timestamps=list(), + sweep_number=-1) def test_sweepNumber_throws_with_NaN(self): electrode_name = GetElectrode() with self.assertRaises(TypeError): - PatchClampSeries('test_pCS', list(), 'unit', - electrode_name, 1.0, timestamps=list(), sweep_number=float('nan')) + PatchClampSeries(name='test_pCS', + data=list(), + unit='unit', + electrodes=electrode_name, + gain=1.0, + timestamps=list(), + sweep_number=float('nan')) def test_sweepNumber_throws_with_Float(self): electrode_name = GetElectrode() with self.assertRaises(TypeError): - PatchClampSeries('test_pCS', list(), 'unit', - electrode_name, 1.0, timestamps=list(), sweep_number=1.5) + PatchClampSeries(name='test_pCS', + data=list(), + unit='unit', + electrodes=electrode_name, + gain=1.0, + timestamps=list(), + sweep_number=1.5) def test_data_shape(self): electrode_name = GetElectrode() @@ -227,7 +261,14 @@ class CurrentClampSeriesConstructor(TestCase): def test_init(self): electrode_name = GetElectrode() - cCS = CurrentClampSeries('test_cCS', list(), electrode_name, 1.0, "stimset", 2.0, 3.0, 4.0, + cCS = CurrentClampSeries(name='test_cCS', + data=list(), + electrode=electrode_name, + gain=1.0, + stimulus_description="stimset", + bias_current=2.0, + bridge_balance=3.0, + capacitance_compensation=4.0, timestamps=list()) self.assertEqual(cCS.name, 'test_cCS') self.assertEqual(cCS.unit, 'volts') @@ -253,7 +294,11 @@ class IZeroClampSeriesConstructor(TestCase): def test_init(self): electrode_name = GetElectrode() - iZCS = IZeroClampSeries('test_iZCS', list(), electrode_name, 1.0, timestamps=list()) + iZCS = IZeroClampSeries(name='test_iZCS', + data=list(), + electrode=electrode_name, + gain=1.0, + timestamps=list()) self.assertEqual(iZCS.name, 'test_iZCS') self.assertEqual(iZCS.unit, 'volts') self.assertEqual(iZCS.electrode, electrode_name) @@ -287,7 +332,11 @@ class CurrentClampStimulusSeriesConstructor(TestCase): def test_init(self): electrode_name = GetElectrode() - cCSS = CurrentClampStimulusSeries('test_cCSS', list(), electrode_name, 1.0, timestamps=list()) + cCSS = CurrentClampStimulusSeries(name='test_cCSS', + data=list(), + electrode=electrode_name, + gain=1.0, + timestamps=list()) self.assertEqual(cCSS.name, 'test_cCSS') self.assertEqual(cCSS.unit, 'amperes') self.assertEqual(cCSS.electrode, electrode_name) @@ -308,8 +357,19 @@ class VoltageClampSeriesConstructor(TestCase): def test_init(self): electrode_name = GetElectrode() - vCS = VoltageClampSeries('test_vCS', list(), electrode_name, - 1.0, "stimset", 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, timestamps=list()) + vCS = VoltageClampSeries(name='test_vCS', + data=list(), + electrode=electrode_name, + gain=1.0, + stimulus_description="stimset", + capacitance_fast=2.0, + capacitance_slow=3.0, + resistance_comp_bandwidth=4.0, + resistance_comp_correction=5.0, + resistance_comp_prediction=6.0, + whole_cell_capacitance_comp=7.0, + whole_cell_series_resistance_comp=8.0, + timestamps=list()) self.assertEqual(vCS.name, 'test_vCS') self.assertEqual(vCS.unit, 'amperes') self.assertEqual(vCS.electrode, electrode_name) @@ -329,8 +389,20 @@ def test_unit_warning(self): msg = "Unit 'unit' for VoltageClampSeries 'test_vCS' is ignored and will be set " \ "to 'amperes' as per NWB 2.1.0." with self.assertWarnsWith(UserWarning, msg): - vCS = VoltageClampSeries('test_vCS', list(), electrode_name, - 1.0, "stimset", 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, timestamps=list(), unit='unit') + vCS = VoltageClampSeries(name='test_vCS', + data=list(), + electrode=electrode_name, + gain=1.0, + stimulus_description="stimset", + capacitance_fast=2.0, + capacitance_slow=3.0, + resistance_comp_bandwidth=4.0, + resistance_comp_correction=5.0, + resistance_comp_prediction=6.0, + whole_cell_capacitance_comp=7.0, + whole_cell_series_resistance_comp=8.0, + timestamps=list(), + unit='unit') self.assertEqual(vCS.unit, 'amperes') @@ -339,7 +411,8 @@ class VoltageClampStimulusSeriesConstructor(TestCase): def test_init(self): electrode_name = GetElectrode() - vCSS = VoltageClampStimulusSeries('test_vCSS', list(), electrode_name, 1.0, timestamps=list()) + vCSS = VoltageClampStimulusSeries(name='test_vCSS', data=list(), electrode=electrode_name, gain=1.0, + timestamps=list()) self.assertEqual(vCSS.name, 'test_vCSS') self.assertEqual(vCSS.unit, 'volts') self.assertEqual(vCSS.electrode, electrode_name) diff --git a/tests/unit/test_icephys_metadata_tables.py b/tests/unit/test_icephys_metadata_tables.py index b31ee9215..7ed9c7432 100644 --- a/tests/unit/test_icephys_metadata_tables.py +++ b/tests/unit/test_icephys_metadata_tables.py @@ -868,7 +868,7 @@ def test_basic_write(self): sw = SimultaneousRecordingsTable(intracellular_recordings_table=ir) row_index = sw.add_simultaneous_recording(recordings=[0]) self.assertEqual(row_index, 0) - sws = SequentialRecordingsTable(sw) + sws = SequentialRecordingsTable(simultaneous_recordings_table=sw) row_index = sws.add_sequential_recording(simultaneous_recordings=[0, ], stimulus_type='MyStimStype') self.assertEqual(row_index, 0) self.write_test_helper(ir=ir, sw=sw, sws=sws) @@ -886,7 +886,7 @@ def test_enforce_unique_id(self): ) sw = SimultaneousRecordingsTable(intracellular_recordings_table=ir) sw.add_simultaneous_recording(recordings=[0]) - sws = SequentialRecordingsTable(sw) + sws = SequentialRecordingsTable(simultaneous_recordings_table=sw) sws.add_sequential_recording(simultaneous_recordings=[0, ], id=np.int64(10), stimulus_type='MyStimStype') with self.assertRaises(ValueError): sws.add_sequential_recording(simultaneous_recordings=[0, ], id=np.int64(10), stimulus_type='MyStimStype') @@ -932,7 +932,7 @@ def test_basic_write(self): sw = SimultaneousRecordingsTable(intracellular_recordings_table=ir) row_index = sw.add_simultaneous_recording(recordings=[0]) self.assertEqual(row_index, 0) - sws = SequentialRecordingsTable(sw) + sws = SequentialRecordingsTable(simultaneous_recordings_table=sw) row_index = sws.add_sequential_recording(simultaneous_recordings=[0, ], stimulus_type='MyStimStype') self.assertEqual(row_index, 0) repetitions = RepetitionsTable(sequential_recordings_table=sws) @@ -952,7 +952,7 @@ def test_enforce_unique_id(self): ) sw = SimultaneousRecordingsTable(intracellular_recordings_table=ir) sw.add_simultaneous_recording(recordings=[0]) - sws = SequentialRecordingsTable(sw) + sws = SequentialRecordingsTable(simultaneous_recordings_table=sw) sws.add_sequential_recording(simultaneous_recordings=[0, ], stimulus_type='MyStimStype') repetitions = RepetitionsTable(sequential_recordings_table=sws) repetitions.add_repetition(sequential_recordings=[0, ], id=np.int64(10)) @@ -999,7 +999,7 @@ def test_basic_write(self): sw = SimultaneousRecordingsTable(intracellular_recordings_table=ir) row_index = sw.add_simultaneous_recording(recordings=[0]) self.assertEqual(row_index, 0) - sws = SequentialRecordingsTable(sw) + sws = SequentialRecordingsTable(simultaneous_recordings_table=sw) row_index = sws.add_sequential_recording(simultaneous_recordings=[0, ], stimulus_type='MyStimStype') self.assertEqual(row_index, 0) repetitions = RepetitionsTable(sequential_recordings_table=sws) @@ -1021,7 +1021,7 @@ def test_enforce_unique_id(self): id=np.int64(10)) sw = SimultaneousRecordingsTable(intracellular_recordings_table=ir) sw.add_simultaneous_recording(recordings=[0]) - sws = SequentialRecordingsTable(sw) + sws = SequentialRecordingsTable(simultaneous_recordings_table=sw) sws.add_sequential_recording(simultaneous_recordings=[0, ], stimulus_type='MyStimStype') repetitions = RepetitionsTable(sequential_recordings_table=sws) repetitions.add_repetition(sequential_recordings=[0, ]) diff --git a/tests/unit/test_image.py b/tests/unit/test_image.py index c279101f5..184ad6edd 100644 --- a/tests/unit/test_image.py +++ b/tests/unit/test_image.py @@ -20,7 +20,7 @@ class ImageSeriesConstructor(TestCase): def test_init(self): - dev = Device('test_device') + dev = Device(name='test_device') iS = ImageSeries( name='test_iS', unit='unit', @@ -411,4 +411,4 @@ def test_rgb_image(self): RGBImage(name='test_rgb_image', data=np.ones((2, 2, 3))) def test_rgba_image(self): - RGBAImage('test_rgba_image', np.ones((2, 2, 4))) + RGBAImage(name='test_rgba_image', data=np.ones((2, 2, 4))) diff --git a/tests/unit/test_misc.py b/tests/unit/test_misc.py index 9350d1d2e..173ac9fdf 100644 --- a/tests/unit/test_misc.py +++ b/tests/unit/test_misc.py @@ -11,14 +11,17 @@ class AnnotationSeriesConstructor(TestCase): def test_init(self): - aS = AnnotationSeries('test_aS', data=[1, 2, 3], timestamps=[1., 2., 3.]) + aS = AnnotationSeries(name='test_aS', data=[1, 2, 3], timestamps=[1., 2., 3.]) self.assertEqual(aS.name, 'test_aS') aS.add_annotation(2.0, 'comment') class AbstractFeatureSeriesConstructor(TestCase): def test_init(self): - aFS = AbstractFeatureSeries('test_aFS', ['feature units'], ['features'], timestamps=list()) + aFS = AbstractFeatureSeries(name='test_aFS', + feature_units=['feature units'], + features=['features'], + timestamps=list()) self.assertEqual(aFS.name, 'test_aFS') self.assertEqual(aFS.feature_units, ['feature units']) self.assertEqual(aFS.features, ['features']) @@ -115,7 +118,7 @@ class IntervalSeriesConstructor(TestCase): def test_init(self): data = [1.0, -1.0, 1.0, -1.0] timestamps = [0.0, 1.0, 2.0, 3.0] - iS = IntervalSeries('test_iS', data=data, timestamps=timestamps) + iS = IntervalSeries(name='test_iS', data=data, timestamps=timestamps) self.assertEqual(iS.name, 'test_iS') self.assertEqual(iS.data, data) self.assertEqual(iS.timestamps, timestamps) @@ -123,7 +126,7 @@ def test_init(self): def test_add_interval(self): data = [1.0, -1.0, 1.0, -1.0] timestamps = [0.0, 1.0, 2.0, 3.0] - iS = IntervalSeries('test_iS', data=data, timestamps=timestamps) + iS = IntervalSeries(name='test_iS', data=data, timestamps=timestamps) iS.add_interval(4.0, 5.0) data.append(1.0) data.append(-1.0) @@ -247,8 +250,11 @@ def test_times_and_intervals(self): def test_electrode_group(self): ut = Units() - device = Device('test_device') - electrode_group = ElectrodeGroup('test_electrode_group', 'description', 'location', device) + device = Device(name='test_device') + electrode_group = ElectrodeGroup(name='test_electrode_group', + description='description', + location='location', + device=device) ut.add_unit(electrode_group=electrode_group) self.assertEqual(ut['electrode_group'][0], electrode_group) diff --git a/tests/unit/test_ogen.py b/tests/unit/test_ogen.py index 678f284dc..15e36bbf7 100644 --- a/tests/unit/test_ogen.py +++ b/tests/unit/test_ogen.py @@ -6,7 +6,7 @@ class OptogeneticSeriesConstructor(TestCase): def test_init(self): - device = Device('name') + device = Device(name='name') oS = OptogeneticStimulusSite( name='site1', device=device,