Skip to content

Commit

Permalink
Change field name and fix docval dtype
Browse files Browse the repository at this point in the history
  • Loading branch information
rly committed Jun 27, 2024
1 parent 7471ec6 commit 944d861
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

### Bug fixes
- Fixed use of `channel_conversion` in `TimeSeries` `get_data_in_units`. @rohanshah [1923](https://github.com/NeurodataWithoutBorders/pynwb/pull/1923)
- Fix support for `bounds` field to `SpatialSeries` to set optional boundary range (min, max) for each dimension of data. @rly [#1907](https://github.com/NeurodataWithoutBorders/pynwb/pull/1907)
- Fix support for `data__bounds` field to `SpatialSeries` to set optional boundary range (min, max) for each dimension of data. @rly [#1907](https://github.com/NeurodataWithoutBorders/pynwb/pull/1907)


## PyNWB 2.8.0 (May 28, 2024)
Expand Down
4 changes: 2 additions & 2 deletions docs/gallery/domain/plot_behavior.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@
#
# For position data ``reference_frame`` indicates the zero-position, e.g.
# the 0,0 point might be the bottom-left corner of an enclosure, as viewed from the tracking camera.
# In :py:class:`~pynwb.behavior.SpatialSeries`, the ``bounds`` field allows the user to set
# In :py:class:`~pynwb.behavior.SpatialSeries`, the ``data__bounds`` field allows the user to set
# the boundary range, i.e., (min, max), for each dimension of ``data``. The units are the same as in ``data``.
# This field does not enforce a boundary on the dataset itself.

Expand All @@ -115,7 +115,7 @@
name="SpatialSeries",
description="Position (x, y) in an open field.",
data=position_data,
bounds=[(0,50), (0,50)],
data__bounds=[(0,50), (0,50)],
timestamps=timestamps,
reference_frame="(0,0) is bottom left corner",
)
Expand Down
8 changes: 4 additions & 4 deletions src/pynwb/behavior.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ class SpatialSeries(TimeSeries):
tracking camera. The unit of data will indicate how to interpret SpatialSeries values.
"""

__nwbfields__ = ('bounds', 'reference_frame',)
__nwbfields__ = ('data__bounds', 'reference_frame',)

@docval(*get_docval(TimeSeries.__init__, 'name'), # required
{'name': 'data', 'type': ('array_data', 'data', TimeSeries), 'shape': ((None, ), (None, None)), # required
'doc': ('The data values. Can be 1D or 2D. The first dimension must be time. If 2D, there can be 1, 2, '
'or 3 columns, which represent x, y, and z.')},
{'name': 'bounds', 'type': list, 'shape': ((1, 2), (2, 2), (3, 2)), 'default': None,
{'name': 'data__bounds', 'type': ('data', 'array_data'), 'shape': ((1, 2), (2, 2), (3, 2)), 'default': None,
'doc': 'The boundary range (min, max) for each dimension of data.'},
{'name': 'reference_frame', 'type': str, # required
'doc': 'description defining what the zero-position is'},
Expand All @@ -38,7 +38,7 @@ def __init__(self, **kwargs):
"""
Create a SpatialSeries TimeSeries dataset
"""
name, data, bounds, reference_frame, unit = popargs('name', 'data', 'bounds', 'reference_frame', 'unit', kwargs)
name, data, data__bounds, reference_frame, unit = popargs('name', 'data', 'data__bounds', 'reference_frame', 'unit', kwargs)
super().__init__(name, data, unit, **kwargs)

# NWB 2.5 restricts length of second dimension to be <= 3
Expand All @@ -49,7 +49,7 @@ def __init__(self, **kwargs):
"The second dimension should have length <= 3 to represent at most x, y, z." %
(name, str(data_shape)))

self.bounds = bounds
self.data__bounds = data__bounds
self.reference_frame = reference_frame

@staticmethod
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/hdf5/test_behavior.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def setUpContainer(self):
return SpatialSeries(
name='test_sS',
data=np.ones((3, 2)),
bounds=[(-1,1),(-1,1),(-1,1)],
data__bounds=[(-1,1),(-1,1),(-1,1)],
reference_frame='reference_frame',
timestamps=[1., 2., 3.]
)
4 changes: 2 additions & 2 deletions tests/unit/test_behavior.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ def test_init(self):
sS = SpatialSeries(
name='test_sS',
data=np.ones((3, 2)),
bounds=[(-1,1),(-1,1),(-1,1)],
data__bounds=[(-1,1),(-1,1),(-1,1)],
reference_frame='reference_frame',
timestamps=[1., 2., 3.]
)
self.assertEqual(sS.name, 'test_sS')
self.assertEqual(sS.unit, 'meters')
self.assertEqual(sS.bounds, [(-1,1),(-1,1),(-1,1)])
self.assertEqual(sS.data__bounds, [(-1,1),(-1,1),(-1,1)])
self.assertEqual(sS.reference_frame, 'reference_frame')

def test_set_unit(self):
Expand Down

0 comments on commit 944d861

Please sign in to comment.