diff --git a/CHANGELOG.md b/CHANGELOG.md index d3f762419..76a32b02c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # PyNWB Changelog +## PyNWB 2.6.1 (Upcoming) + +### Bug fixes +- Fix bug where extra keyword arguments could not be passed to `NWBFile.add_{x}_column`` for use in custom `VectorData`` classes. @rly [#1861](https://github.com/NeurodataWithoutBorders/pynwb/pull/1861) + ## PyNWB 2.6.0 (February 21, 2024) ### Enhancements and minor changes diff --git a/tests/unit/test_file.py b/tests/unit/test_file.py index 756009ff3..094b7e120 100644 --- a/tests/unit/test_file.py +++ b/tests/unit/test_file.py @@ -4,6 +4,7 @@ from datetime import datetime, timedelta from dateutil.tz import tzlocal, tzutc +from hdmf.common import VectorData from pynwb import NWBFile, TimeSeries, NWBHDF5IO from pynwb.base import Image, Images from pynwb.file import Subject, ElectrodeTable, _add_missing_timezone @@ -222,6 +223,27 @@ def test_add_trial_column(self): self.nwbfile.add_trial_column('trial_type', 'the type of trial') self.assertEqual(self.nwbfile.trials.colnames, ('start_time', 'stop_time', 'trial_type')) + def test_add_trial_column_custom_class(self): + class SubVectorData(VectorData): + __fields__ = ('extra_kwarg') + + @docval( + *get_docval(VectorData.__init__, "name", "description", "data"), + {'name': 'extra_kwarg', 'type': 'str', 'doc': 'An extra kwarg.'}, + ) + def __init__(self, **kwargs): + extra_kwarg = popargs('extra_kwarg', kwargs) + super().__init__(**kwargs) + self.extra_kwarg = extra_kwarg + + self.nwbfile.add_trial_column( + name="test", + description="test", + col_cls=SubVectorData, + extra_kwarg="test_extra_kwarg" + ) + self.assertEqual(self.nwbfile.trials["test"].extra_kwarg, "test_extra_kwarg") + def test_add_trial(self): self.nwbfile.add_trial(start_time=10.0, stop_time=20.0) self.assertEqual(len(self.nwbfile.trials), 1)