Skip to content

Commit

Permalink
Fix ruff and some test failures
Browse files Browse the repository at this point in the history
  • Loading branch information
oruebel committed Feb 6, 2025
1 parent ff1611c commit e55a004
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/pynwb/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,15 +114,15 @@ class ScratchData(NWBData):
@docval({'name': 'name', 'type': str, 'doc': 'the name of this container'},
{'name': 'data', 'type': ('scalar_data', 'array_data', 'data', Data), 'doc': 'the source of the data'},
{'name': 'notes', 'type': str,
'doc': 'notes about the data. This argument will be deprecated. Use description instead', 'default': ''},
'doc': 'notes about the data. This argument will be deprecated. Use description instead', 'default': None},
{'name': 'description', 'type': str, 'doc': 'notes about the data', 'default': None})
def __init__(self, **kwargs):
notes, description = popargs('notes', 'description', kwargs)
super().__init__(**kwargs)
if notes != '':
if notes is not None:
warn('The `notes` argument of ScratchData.__init__ will be deprecated. Use description instead.',
PendingDeprecationWarning)
if notes != '' and description != '':
if notes is not None and description is not None:
raise ValueError('Cannot provide both notes and description to ScratchData.__init__. The description '
'argument is recommended.')
description = notes
Expand Down
9 changes: 6 additions & 3 deletions tests/unit/test_scratch.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,16 @@ def test_notes_deprecation(self):
ScratchData(name='foo', data=[1, 2, 3, 4], notes='notes')
with self.assertRaises(ValueError):
ScratchData(name='foo', data=[1, 2, 3, 4], description='test scratch', notes='notes')
with self.assertWarnsWith(PendingDeprecationWarning, 'ScratchData.description will be required in a future major release of PyNWB.'):
with self.assertWarnsWith(PendingDeprecationWarning,
'ScratchData.description will be required in a future major release of PyNWB.'):
ScratchData(name='foo', data=[1, 2, 3, 4])
# test getting and setting notes after the fact
testScratch = ScratchData(name='foo', data=[1, 2, 3, 4], description='test scratch')
with self.assertWarnsWith(PendingDeprecationWarning, 'Use of ScratchData.notes will be deprecated. Use ScratchData.description instead.'):
with self.assertWarnsWith(PendingDeprecationWarning,
'Use of ScratchData.notes will be deprecated. Use ScratchData.description instead.'):
testScratch.notes
with self.assertWarnsWith(PendingDeprecationWarning, 'Use of ScratchData.notes will be deprecated. Use ScratchData.description instead.'):
with self.assertWarnsWith(PendingDeprecationWarning,
'Use of ScratchData.notes will be deprecated. Use ScratchData.description instead.'):
testScratch.notes = 'new notes'

def test_add_scratch_int(self):
Expand Down

0 comments on commit e55a004

Please sign in to comment.