Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add unique electrode id check #1344

Merged
7 changes: 5 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
# PyNWB Changelog

## PyNWB 1.6.0 (TBD, 2021)

## PyNWB 2.0.0
## Minor new features:
- Add RRID for citing PyNWB to the docs. @oruebel (#1372)

- Add RRID for citing PyNWB to the docs @oruebel (#1372)
## Bug fix:
- Enforce electrode ID uniqueness during insertion into table. @CodyCBakerPhD (#1344)


## PyNWB 1.5.1 (May 24, 2021)
Expand Down
2 changes: 2 additions & 0 deletions src/pynwb/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,8 @@ def add_electrode_column(self, **kwargs):
{'name': 'rel_z', 'type': 'float', 'doc': 'the z coordinate within the electrode group', 'default': None},
{'name': 'reference', 'type': str, 'doc': 'Description of the reference used for this electrode.',
'default': None},
{'name': 'enforce_unique_id', 'type': bool, 'doc': 'enforce that the id in the table must be unique',
'default': True},
allow_extra=True)
def add_electrode(self, **kwargs):
"""
Expand Down
10 changes: 10 additions & 0 deletions tests/integration/test_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,16 @@ def test_append(self):
errors = validate(io)
self.assertTrue(len(errors) == 0)

def test_electrode_id_uniqueness(self):
device = self.nwbfile.create_device(name='test_device')
e_group = self.nwbfile.create_electrode_group(name='test_electrode_group',
description='',
location='',
device=device)
self.nwbfile.add_electrode(id=0, x=0.0, y=0.0, z=0.0, imp=np.nan, location='', filtering='', group=e_group)
with self.assertRaises(ValueError):
self.nwbfile.add_electrode(id=0, x=0.0, y=0.0, z=0.0, imp=np.nan, location='', filtering='', group=e_group)


class TestH5DataIO(TestCase):
"""
Expand Down