Skip to content

Commit

Permalink
Use HDMF 1.5.4 (#1154)
Browse files Browse the repository at this point in the history
* Use HDMF 1.5.4

* Rename mixin classes to not start with Test* (#1153)

* Rename mixin classes to not start with Test*

* flake8 fix

* Use hdmf 1.5.4

* Use hdmf 1.5.4

* Add version to NWBNamespaceBuilder tests

* Add version to NWBNamespaceBuilder in extensions tutorial

* Add version 1.1.2 files for backwards compatibility tests
  • Loading branch information
rly authored Jan 22, 2020
1 parent 35e875a commit cec8971
Show file tree
Hide file tree
Showing 20 changed files with 69 additions and 72 deletions.
6 changes: 3 additions & 3 deletions docs/gallery/general/extensions.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
ns_path = "mylab.namespace.yaml"
ext_source = "mylab.extensions.yaml"

ns_builder = NWBNamespaceBuilder('Extension for use in my Lab', "mylab")
ns_builder = NWBNamespaceBuilder('Extension for use in my Lab', "mylab", version='0.1.0')

ns_builder.include_type('ElectricalSeries', namespace='core')

Expand Down Expand Up @@ -252,7 +252,7 @@ def __init__(self, **kwargs):
ns_path = name + ".namespace.yaml"
ext_source = name + ".extensions.yaml"

ns_builder = NWBNamespaceBuilder(name + ' extensions', name)
ns_builder = NWBNamespaceBuilder(name + ' extensions', name, version='0.1.0')
ns_builder.include_type('NWBDataInterface', namespace='core')

potato = NWBGroupSpec(neurodata_type_def='Potato',
Expand Down Expand Up @@ -387,7 +387,7 @@ class PotatoSack(MultiContainerInterface):

# Now we set up the builder and add this object

ns_builder = NWBNamespaceBuilder(name + ' extensions', name)
ns_builder = NWBNamespaceBuilder(name + ' extensions', name, version='0.1.0')
ns_builder.add_spec(ext_source, surface)
ns_builder.export(ns_path)

Expand Down
2 changes: 1 addition & 1 deletion docs/source/extensions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ Create a new namespace with extensions
from pynwb.spec import NWBGroupSpec, NWBNamespaceBuilder
# create a builder for the namespace
ns_builder = NWBNamespaceBuilder("Extension for use in my laboratory", "mylab", ...)
ns_builder = NWBNamespaceBuilder("Extension for use in my laboratory", "mylab", version='0.1.0', ...)
# create extensions
ext1 = NWBGroupSpec('A custom SpikeEventSeries interface',
Expand Down
2 changes: 1 addition & 1 deletion requirements-min.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# these minimum requirements specify '==' for testing; setup.py replaces '==' with '>='
h5py==2.9 # support for setting attrs to lists of utf-8 added in 2.9
hdmf==1.5.3,<2
hdmf==1.5.4,<2
numpy==1.16
pandas==0.23
python-dateutil==2.7
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
h5py==2.10.0
hdmf==1.5.3
hdmf==1.5.4
numpy==1.18.1
pandas==0.25.3
python-dateutil==2.8.0
4 changes: 2 additions & 2 deletions src/pynwb/testing/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from hdmf.testing import TestCase, TestH5RoundTripMixin
from .testh5io import TestNWBH5IOMixin, TestAcquisitionH5IOMixin
from hdmf.testing import TestCase, H5RoundTripMixin
from .testh5io import NWBH5IOMixin, AcquisitionH5IOMixin
from .utils import remove_test_file

CORE_NAMESPACE = 'core'
12 changes: 6 additions & 6 deletions src/pynwb/testing/testh5io.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from hdmf.build.warnings import MissingRequiredWarning, OrphanContainerWarning


class TestNWBH5IOMixin(metaclass=ABCMeta):
class NWBH5IOMixin(metaclass=ABCMeta):
"""
Mixin class for methods to run a roundtrip test writing an NWB file with an Container and reading the Container
from the NWB file. The setUp, test_roundtrip, and tearDown methods will be run by unittest.
Expand All @@ -19,15 +19,15 @@ class TestNWBH5IOMixin(metaclass=ABCMeta):
this mixin.
Example:
class TestMyContainerIO(TestNWBH5IOMixin, TestCase):
class TestMyContainerIO(NWBH5IOMixin, TestCase):
def setUpContainer(self):
# return a test Container to read/write
def addContainer(self, nwbfile):
# add the test Container to an NWB file
def getContainer(self, nwbfile):
# return the test Container from an NWB file
This code is adapted from hdmf.testing.TestH5RoundTripMixin.
This code is adapted from hdmf.testing.H5RoundTripMixin.
"""

def setUp(self):
Expand Down Expand Up @@ -120,7 +120,7 @@ def validate(self):
raise Exception(err)


class TestAcquisitionH5IOMixin(TestNWBH5IOMixin):
class AcquisitionH5IOMixin(NWBH5IOMixin):
"""
Mixin class for methods to run a roundtrip test writing an NWB file with an Container as an acquisition and reading
the Container as an acquisition from the NWB file. The setUp, test_roundtrip, and tearDown methods will be run by
Expand All @@ -129,11 +129,11 @@ class TestAcquisitionH5IOMixin(TestNWBH5IOMixin):
The abstract method setUpContainer needs to be implemented by classes that include this mixin.
Example:
class TestMyContainerIO(TestNWBH5IOMixin, TestCase):
class TestMyContainerIO(NWBH5IOMixin, TestCase):
def setUpContainer(self):
# return a test Container to read/write
This code is adapted from hdmf.testing.TestH5RoundTripMixin.
This code is adapted from hdmf.testing.H5RoundTripMixin.
"""

def addContainer(self, nwbfile):
Expand Down
Binary file added tests/back_compat/1.1.2_nwbfile.nwb
Binary file not shown.
Binary file added tests/back_compat/1.1.2_str_experimenter.nwb
Binary file not shown.
Binary file added tests/back_compat/1.1.2_str_pub.nwb
Binary file not shown.
4 changes: 2 additions & 2 deletions tests/integration/hdf5/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
from dateutil.tz import tzlocal

from pynwb import TimeSeries, NWBFile, NWBHDF5IO
from pynwb.testing import TestAcquisitionH5IOMixin, TestCase
from pynwb.testing import AcquisitionH5IOMixin, TestCase


class TestTimeSeriesIO(TestAcquisitionH5IOMixin, TestCase):
class TestTimeSeriesIO(AcquisitionH5IOMixin, TestCase):

def setUpContainer(self):
""" Return the test TimeSeries to read/write """
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/hdf5/test_device.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from pynwb.device import Device
from pynwb.testing import TestNWBH5IOMixin, TestCase
from pynwb.testing import NWBH5IOMixin, TestCase


class TestDeviceIO(TestNWBH5IOMixin, TestCase):
class TestDeviceIO(NWBH5IOMixin, TestCase):

def setUpContainer(self):
""" Return the test Device to read/write """
Expand Down
22 changes: 11 additions & 11 deletions tests/integration/hdf5/test_ecephys.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
SpikeEventSeries, EventWaveform, EventDetection, FeatureExtraction
from pynwb.device import Device
from pynwb.file import ElectrodeTable as get_electrode_table
from pynwb.testing import TestNWBH5IOMixin, TestAcquisitionH5IOMixin, TestCase
from pynwb.testing import NWBH5IOMixin, AcquisitionH5IOMixin, TestCase


class TestElectrodeGroupIO(TestNWBH5IOMixin, TestCase):
class TestElectrodeGroupIO(NWBH5IOMixin, TestCase):

def setUpContainer(self):
""" Return the test ElectrodeGroup to read/write """
Expand All @@ -25,7 +25,7 @@ def getContainer(self, nwbfile):
return nwbfile.get_electrode_group(self.container.name)


class TestElectricalSeriesIO(TestAcquisitionH5IOMixin, TestCase):
class TestElectricalSeriesIO(AcquisitionH5IOMixin, TestCase):

@staticmethod
def make_electrode_table(self):
Expand Down Expand Up @@ -66,7 +66,7 @@ def test_eg_ref(self):
self.assertIsInstance(row2.iloc[0]['group'], ElectrodeGroup)


class TestMultiElectricalSeriesIOMixin(TestAcquisitionH5IOMixin):
class MultiElectricalSeriesIOMixin(AcquisitionH5IOMixin):
"""
Mixin class for methods to run a roundtrip test writing an NWB file with multiple ElectricalSeries.
Expand Down Expand Up @@ -95,7 +95,7 @@ def addContainer(self, nwbfile):
nwbfile.add_acquisition(self.container)


class TestLFPIO(TestMultiElectricalSeriesIOMixin, TestCase):
class TestLFPIO(MultiElectricalSeriesIOMixin, TestCase):

def setUpContainer(self):
""" Return a test LFP to read/write """
Expand All @@ -104,7 +104,7 @@ def setUpContainer(self):
return lfp


class TestFilteredEphysIO(TestMultiElectricalSeriesIOMixin, TestCase):
class TestFilteredEphysIO(MultiElectricalSeriesIOMixin, TestCase):

def setUpContainer(self):
""" Return a test FilteredEphys to read/write """
Expand All @@ -113,7 +113,7 @@ def setUpContainer(self):
return fe


class TestClusteringIO(TestAcquisitionH5IOMixin, TestCase):
class TestClusteringIO(AcquisitionH5IOMixin, TestCase):

def setUpContainer(self):
""" Return a test Clustering to read/write """
Expand All @@ -127,7 +127,7 @@ def roundtripContainer(self, cache_spec=False):
return super().roundtripContainer(cache_spec)


class EventWaveformConstructor(TestAcquisitionH5IOMixin, TestCase):
class EventWaveformConstructor(AcquisitionH5IOMixin, TestCase):

def setUpContainer(self):
""" Return a test EventWaveform to read/write """
Expand All @@ -145,7 +145,7 @@ def addContainer(self, nwbfile):
nwbfile.add_acquisition(self.container)


class ClusterWaveformsConstructor(TestAcquisitionH5IOMixin, TestCase):
class ClusterWaveformsConstructor(AcquisitionH5IOMixin, TestCase):

def setUpContainer(self):
""" Return a test ClusterWaveforms to read/write """
Expand All @@ -171,7 +171,7 @@ def roundtripContainer(self, cache_spec=False):
return super().roundtripContainer(cache_spec)


class FeatureExtractionConstructor(TestAcquisitionH5IOMixin, TestCase):
class FeatureExtractionConstructor(AcquisitionH5IOMixin, TestCase):

def setUpContainer(self):
""" Return a test FeatureExtraction to read/write """
Expand All @@ -191,7 +191,7 @@ def addContainer(self, nwbfile):
nwbfile.add_acquisition(self.container)


class EventDetectionConstructor(TestAcquisitionH5IOMixin, TestCase):
class EventDetectionConstructor(AcquisitionH5IOMixin, TestCase):

def setUpContainer(self):
""" Return a test EventDetection to read/write """
Expand Down
12 changes: 5 additions & 7 deletions tests/integration/hdf5/test_icephys.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
from abc import ABCMeta

from pynwb import NWBFile
from pynwb.icephys import (IntracellularElectrode, PatchClampSeries, CurrentClampStimulusSeries,
SweepTable, VoltageClampStimulusSeries, CurrentClampSeries,
VoltageClampSeries, IZeroClampSeries)
from pynwb.device import Device
from pynwb.testing import TestNWBH5IOMixin, TestAcquisitionH5IOMixin, TestCase
from pynwb.testing import NWBH5IOMixin, AcquisitionH5IOMixin, TestCase


class TestIntracellularElectrode(TestNWBH5IOMixin, TestCase):
class TestIntracellularElectrode(NWBH5IOMixin, TestCase):

def setUpContainer(self):
""" Return the test IntracellularElectrode to read/write """
Expand All @@ -32,7 +30,7 @@ def getContainer(self, nwbfile):
return nwbfile.get_ic_electrode(self.container.name)


class TestPatchClampSeries(TestAcquisitionH5IOMixin, metaclass=ABCMeta):
class TestPatchClampSeries(AcquisitionH5IOMixin, TestCase):

def setUpElectrode(self):
""" Set up the test IntracellularElectrode """
Expand Down Expand Up @@ -111,7 +109,7 @@ def setUpContainer(self):
starting_time=123.6, rate=10e3, electrode=self.elec, gain=0.126)


class TestSweepTableRoundTripEasy(TestNWBH5IOMixin, TestCase):
class TestSweepTableRoundTripEasy(NWBH5IOMixin, TestCase):

def setUpContainer(self):
""" Return the test SweepTable to read/write """
Expand Down Expand Up @@ -154,7 +152,7 @@ def test_container(self):
self.assertEqual(sweep_table['sweep_number'].data[0], 4711)


class TestSweepTableRoundTripComplicated(TestNWBH5IOMixin, TestCase):
class TestSweepTableRoundTripComplicated(NWBH5IOMixin, TestCase):

def setUpContainer(self):
""" Return the test SweepTable to read/write """
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/hdf5/test_image.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import numpy as np

from pynwb.image import OpticalSeries
from pynwb.testing import TestNWBH5IOMixin, TestCase
from pynwb.testing import NWBH5IOMixin, TestCase


class TestOpticalSeriesIO(TestNWBH5IOMixin, TestCase):
class TestOpticalSeriesIO(NWBH5IOMixin, TestCase):

def setUpContainer(self):
""" Return a test OpticalSeries to read/write """
Expand Down
8 changes: 4 additions & 4 deletions tests/integration/hdf5/test_misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
from hdmf.common import DynamicTable, VectorData
from pynwb import TimeSeries
from pynwb.misc import Units, DecompositionSeries
from pynwb.testing import TestNWBH5IOMixin, TestAcquisitionH5IOMixin, TestCase
from pynwb.testing import NWBH5IOMixin, AcquisitionH5IOMixin, TestCase


class TestUnitsIO(TestAcquisitionH5IOMixin, TestCase):
class TestUnitsIO(AcquisitionH5IOMixin, TestCase):
""" Test adding Units into acquisition and accessing Units after read """

def setUpContainer(self):
Expand Down Expand Up @@ -35,7 +35,7 @@ def test_get_obs_intervals(self):
self.assertTrue(np.array_equal(ut['obs_intervals'][:], [[[0, 1], [2, 3]], [[2, 5], [6, 7]]]))


class TestUnitsFileIO(TestNWBH5IOMixin, TestCase):
class TestUnitsFileIO(NWBH5IOMixin, TestCase):

def setUpContainer(self):
""" Return placeholder Units object. Tested units are added directly to the NWBFile in addContainer """
Expand Down Expand Up @@ -71,7 +71,7 @@ def test_to_dataframe(self):
units.to_dataframe()


class TestDecompositionSeriesIO(TestNWBH5IOMixin, TestCase):
class TestDecompositionSeriesIO(NWBH5IOMixin, TestCase):

def setUpContainer(self):
""" Return the test DecompositionSeries to read/write """
Expand Down
Loading

0 comments on commit cec8971

Please sign in to comment.