Skip to content

Commit

Permalink
Merge branch 'dev' into schema_2.2.3
Browse files Browse the repository at this point in the history
  • Loading branch information
rly authored May 28, 2020
2 parents 0f539c6 + 16e73d9 commit 0faa8c2
Show file tree
Hide file tree
Showing 16 changed files with 259 additions and 133 deletions.
2 changes: 1 addition & 1 deletion docs/CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ How to contribute to NWB:N software and documents
Code of Conduct
---------------

This project and everyone participating in it is governed by our `code of conduct guidelines <https://github.com/NeurodataWithoutBorders/pynwb/blob/dev/.github/CONTRIBUTING.rst>`_. By participating, you are expected to uphold this code. Please report unacceptable behavior.
This project and everyone participating in it is governed by our `code of conduct guidelines <https://github.com/NeurodataWithoutBorders/pynwb/blob/dev/.github/CODE_OF_CONDUCT.rst>`_. By participating, you are expected to uphold this code. Please report unacceptable behavior.

.. _sec-contribution-types:

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.6.1,<2
hdmf==1.6.2,<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.6.1
hdmf==1.6.2
numpy==1.18.1
pandas==0.25.3
python-dateutil==2.8.1
8 changes: 4 additions & 4 deletions src/pynwb/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@ def _get_resources():
@docval({'name': 'extensions', 'type': (str, TypeMap, list),
'doc': 'a path to a namespace, a TypeMap, or a list consisting of paths to namespaces and TypeMaps',
'default': None},
returns="the namespaces loaded from the given file", rtype=tuple,
returns="TypeMap loaded for the given extension or NWB core namespace", rtype=tuple,
is_method=False)
def get_type_map(**kwargs):
'''
Get a BuildManager to use for I/O using the given extensions. If no extensions are provided,
return a BuildManager that uses the core namespace
Get the TypeMap for the given extensions. If no extensions are provided,
return the TypeMap for the core namespace
'''
extensions = getargs('extensions', kwargs)
type_map = None
Expand Down Expand Up @@ -227,7 +227,7 @@ def __init__(self, **kwargs):
raise ValueError("cannot load namespaces from file when writing to it")

tm = get_type_map()
super(NWBHDF5IO, self).load_namespaces(tm, path)
super(NWBHDF5IO, self).load_namespaces(tm, path, file=file_obj)
manager = BuildManager(tm)

# XXX: Leaving this here in case we want to revert to this strategy for
Expand Down
2 changes: 1 addition & 1 deletion src/pynwb/legacy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@ def _dec(cls):
_dec(mapper_cls)


from . import io # noqa: F401
from . import io # noqa: F401,E402
4 changes: 2 additions & 2 deletions test.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,9 +197,9 @@ def main():

# set up logger
root = logging.getLogger()
root.setLevel(logging.DEBUG)
root.setLevel(logging.INFO)
ch = logging.StreamHandler(sys.stdout)
ch.setLevel(logging.DEBUG)
ch.setLevel(logging.INFO)
formatter = logging.Formatter('======================================================================\n'
'%(asctime)s - %(levelname)s - %(message)s')
ch.setFormatter(formatter)
Expand Down
2 changes: 1 addition & 1 deletion tests/coloredtestrunner.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def __len__(self, x):
return len(re.sub(r"\033\[[0-9];[0-9];[0-9]{1,2}m", "", x))

def addRow(self, row):
rows = [[''] for l in range(len(row))]
rows = [[''] for i in range(len(row))]
maxrows = 0
for i, x in enumerate(row):
for j, y in enumerate(x.split("\n")):
Expand Down
11 changes: 8 additions & 3 deletions tests/integration/hdf5/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,13 @@ class TestTimeSeriesIO(AcquisitionH5IOMixin, TestCase):

def setUpContainer(self):
""" Return the test TimeSeries to read/write """
return TimeSeries('test_timeseries', list(range(100, 200, 10)),
'SIunit', timestamps=list(range(10)), resolution=0.1)
return TimeSeries(
name='test_timeseries',
data=list(range(1000)),
unit='SIunit',
timestamps=np.arange(1000.),
resolution=0.1
)


class TestTimeSeriesLinking(TestCase):
Expand All @@ -24,7 +29,7 @@ def tearDown(self):

def test_timestamps_linking(self):
''' Test that timestamps get linked to in TimeSeries '''
tsa = TimeSeries(name='a', data=np.linspace(0, 1, 1000), timestamps=np.arange(1000), unit='m')
tsa = TimeSeries(name='a', data=np.linspace(0, 1, 1000), timestamps=np.arange(1000.), unit='m')
tsb = TimeSeries(name='b', data=np.linspace(0, 1, 1000), timestamps=tsa, unit='m')
nwbfile = NWBFile(identifier='foo',
session_start_time=datetime(2017, 5, 1, 12, 0, 0, tzinfo=tzlocal()),
Expand Down
74 changes: 54 additions & 20 deletions tests/integration/hdf5/test_ecephys.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,11 @@ class TestElectrodeGroupIO(NWBH5IOMixin, TestCase):

def setUpContainer(self):
""" Return the test ElectrodeGroup to read/write """
self.dev1 = Device('dev1')
eg = ElectrodeGroup('elec1', 'a test ElectrodeGroup', 'a nonexistent place', self.dev1)
self.dev1 = Device(name='dev1')
eg = ElectrodeGroup(name='elec1',
description='a test ElectrodeGroup',
location='a nonexistent place',
device=self.dev1)
return eg

def addContainer(self, nwbfile):
Expand All @@ -31,20 +34,29 @@ class TestElectricalSeriesIO(AcquisitionH5IOMixin, TestCase):
def make_electrode_table(self):
""" Make an electrode table, electrode group, and device """
self.table = get_electrode_table()
self.dev1 = Device('dev1')
self.group = ElectrodeGroup('tetrode1',
'tetrode description', 'tetrode location', self.dev1)
self.dev1 = Device(name='dev1')
self.group = ElectrodeGroup(name='tetrode1',
description='tetrode description',
location='tetrode location',
device=self.dev1)
for i in range(4):
self.table.add_row(x=i, y=2.0, z=3.0, imp=-1.0, location='CA1', filtering='none', group=self.group,
group_name='tetrode1')

def setUpContainer(self):
""" Return the test ElectricalSeries to read/write """
self.make_electrode_table(self)
region = DynamicTableRegion('electrodes', [0, 2], 'the first and third electrodes', self.table)
region = DynamicTableRegion(name='electrodes',
data=[0, 2],
description='the first and third electrodes',
table=self.table)
data = list(zip(range(10), range(10, 20)))
timestamps = list(map(lambda x: x/10, range(10)))
es = ElectricalSeries('test_eS', data, region, channel_conversion=[4., .4], timestamps=timestamps)
timestamps = list(map(lambda x: x/10., range(10)))
es = ElectricalSeries(name='test_eS',
data=data,
electrodes=region,
channel_conversion=[4., .4],
timestamps=timestamps)
return es

def addContainer(self, nwbfile):
Expand Down Expand Up @@ -78,13 +90,20 @@ def setUpContainer(self):
def setUpTwoElectricalSeries(self):
""" Return two test ElectricalSeries to read/write """
TestElectricalSeriesIO.make_electrode_table(self)
region1 = DynamicTableRegion('electrodes', [0, 2], 'the first and third electrodes', self.table)
region2 = DynamicTableRegion('electrodes', [1, 3], 'the second and fourth electrodes', self.table)
region1 = DynamicTableRegion(name='electrodes',
data=[0, 2],
description='the first and third electrodes',
table=self.table)
region2 = DynamicTableRegion(name='electrodes',
data=[1, 3],
description='the second and fourth electrodes',
table=self.table)
data1 = list(zip(range(10), range(10, 20)))
data2 = list(zip(reversed(range(10)), reversed(range(10, 20))))
timestamps = list(map(lambda x: x/10, range(10)))
es1 = ElectricalSeries('test_eS1', data1, region1, timestamps=timestamps)
es2 = ElectricalSeries('test_eS2', data2, region2, channel_conversion=[4., .4], timestamps=timestamps)
timestamps = list(map(lambda x: x/10., range(10)))
es1 = ElectricalSeries(name='test_eS1', data=data1, electrodes=region1, timestamps=timestamps)
es2 = ElectricalSeries(name='test_eS2', data=data2, electrodes=region2, channel_conversion=[4., .4],
timestamps=timestamps)
return es1, es2

def addContainer(self, nwbfile):
Expand Down Expand Up @@ -132,8 +151,14 @@ class EventWaveformConstructor(AcquisitionH5IOMixin, TestCase):
def setUpContainer(self):
""" Return a test EventWaveform to read/write """
TestElectricalSeriesIO.make_electrode_table(self)
region = DynamicTableRegion('electrodes', [0, 2], 'the first and third electrodes', self.table)
sES = SpikeEventSeries('test_sES', ((1, 1, 1), (2, 2, 2)), list(range(2)), region)
region = DynamicTableRegion(name='electrodes',
data=[0, 2],
description='the first and third electrodes',
table=self.table)
sES = SpikeEventSeries(name='test_sES',
data=((1, 1, 1), (2, 2, 2)),
timestamps=[0., 1.],
electrodes=region)
ew = EventWaveform(sES)
return ew

Expand Down Expand Up @@ -177,10 +202,13 @@ def setUpContainer(self):
""" Return a test FeatureExtraction to read/write """
event_times = [1.9, 3.5]
TestElectricalSeriesIO.make_electrode_table(self)
region = DynamicTableRegion('electrodes', [0, 2], 'the first and third electrodes', self.table)
region = DynamicTableRegion(name='electrodes',
data=[0, 2],
description='the first and third electrodes',
table=self.table)
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)
return fe

def addContainer(self, nwbfile):
Expand All @@ -196,11 +224,17 @@ class EventDetectionConstructor(AcquisitionH5IOMixin, TestCase):
def setUpContainer(self):
""" Return a test EventDetection to read/write """
TestElectricalSeriesIO.make_electrode_table(self)
region = DynamicTableRegion('electrodes', [0, 2], 'the first and third electrodes', self.table)
region = DynamicTableRegion(name='electrodes',
data=[0, 2],
description='the first and third electrodes',
table=self.table)
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]
self.eS = ElectricalSeries('test_eS', data, region, timestamps=ts)
eD = EventDetection('detection_method', self.eS, (1, 2, 3), (0.1, 0.2, 0.3))
self.eS = ElectricalSeries(name='test_eS', data=data, electrodes=region, timestamps=ts)
eD = EventDetection(detection_method='detection_method',
source_electricalseries=self.eS,
source_idx=(1, 2, 3),
times=(0.1, 0.2, 0.3))
return eD

def addContainer(self, nwbfile):
Expand Down
18 changes: 10 additions & 8 deletions tests/integration/hdf5/test_icephys.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,15 @@ class TestIntracellularElectrode(NWBH5IOMixin, TestCase):
def setUpContainer(self):
""" Return the test IntracellularElectrode to read/write """
self.device = Device(name='device_name')
elec = IntracellularElectrode(name="elec0", slice='tissue slice',
resistance='something measured in ohms',
seal='sealing method', description='a fake electrode object',
location='Springfield Elementary School',
filtering='a meaningless free-form text field',
initial_access_resistance='I guess this changes',
device=self.device)
elec = IntracellularElectrode(name="elec0",
slice='tissue slice',
resistance='something measured in ohms',
seal='sealing method',
description='a fake electrode object',
location='Springfield Elementary School',
filtering='a meaningless free-form text field',
initial_access_resistance='I guess this changes',
device=self.device)
return elec

def addContainer(self, nwbfile):
Expand Down Expand Up @@ -50,7 +52,7 @@ def setUpContainer(self):
self.setUpElectrode()
return PatchClampSeries(name="pcs", data=[1, 2, 3, 4, 5], unit='A',
starting_time=123.6, rate=10e3, electrode=self.elec, gain=0.126,
stimulus_description="gotcha ya!", sweep_number=4711)
stimulus_description="gotcha ya!", sweep_number=np.uint(4711))

def addContainer(self, nwbfile):
"""
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/hdf5/test_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def setUpContainer(self):
data=np.ones((10, 3, 3)),
unit='m',
format='raw',
timestamps=np.arange(10))
timestamps=np.arange(10.))
return self.optical_series

def addContainer(self, nwbfile):
Expand Down
Loading

0 comments on commit 0faa8c2

Please sign in to comment.