Skip to content

Commit

Permalink
Merge branch 'dev' into add-spikeeventseries-docs
Browse files Browse the repository at this point in the history
  • Loading branch information
rly authored Nov 8, 2024
2 parents d7d4436 + 1bdffe8 commit 6930a94
Show file tree
Hide file tree
Showing 10 changed files with 39 additions and 10 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
- Fixed bug in how `ElectrodeGroup.__init__` validates its `position` argument. @oruebel [#1770](https://github.com/NeurodataWithoutBorders/pynwb/pull/1770)
- Changed `SpatialSeries.reference_frame` from required to optional as specified in the schema. @rly [#1986](https://github.com/NeurodataWithoutBorders/pynwb/pull/1986)

### Enhancements and minor changes`
- Added warning when writing files with `NWBHDF5IO` without the `.nwb` extension. @stephprince [#1978](https://github.com/NeurodataWithoutBorders/pynwb/pull/1978)

## PyNWB 2.8.2 (September 9, 2024)

### Enhancements and minor changes
Expand Down
3 changes: 3 additions & 0 deletions docs/gallery/advanced_io/plot_editing.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
First, let's create an NWB file with data:
"""

# sphinx_gallery_thumbnail_path = "figures/gallery_thumbnails_editing.png"

from pynwb import NWBHDF5IO, NWBFile, TimeSeries
from datetime import datetime
from dateutil.tz import tzlocal
Expand Down
10 changes: 6 additions & 4 deletions docs/gallery/general/plot_configurator.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,18 @@
Introduction
-------------
Users will create a configuration YAML file that outlines the fields (within a neurodata type)
they want to be validated against a set of allowed terms.
they want to be validated against a set of allowed terms.
After creating the configuration file, users will need to load the
configuration file with the :py:func:`~pynwb.load_type_config` method.
With the configuration loaded, every instance of the neurodata
types defined in the configuration file will have the respective fields wrapped with a
:py:class:`~hdmf.term_set.TermSetWrapper`.
This automatic wrapping is what provides the term validation for the field value.
For greater control on which datasets and attributes are validated
against which sets of allowed terms, use the
against which sets of allowed terms, use the
:py:class:`~hdmf.term_set.TermSetWrapper` on individual datasets and attributes instead.
You can follow the
`TermSet tutorial in the HDMF documentation
You can follow the
`TermSet tutorial in the HDMF documentation
<https://hdmf.readthedocs.io/en/stable/tutorials/plot_term_set.html#sphx-glr-tutorials-plot-term-set-py>`_
for more information.
Expand All @@ -42,6 +42,8 @@
3. Each data type will have a list of fields associated with a :py:class:`~hdmf.term_set.TermSet`.
The user can use the same or unique TermSet instances for each field.
"""
# sphinx_gallery_thumbnail_path = 'figures/gallery_thumbnails_configurator.png'

try:
import linkml_runtime # noqa: F401
except ImportError as e:
Expand Down
Binary file modified docs/source/figures/gallery_thumbnails.pptx
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions src/pynwb/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,10 @@ def __init__(self, **kwargs):
if mode in io_modes_that_create_file or manager is not None or extensions is not None:
load_namespaces = False

if mode in io_modes_that_create_file and not str(path).endswith('.nwb'):
warn(f"The file path provided: {path} does not end in '.nwb'. "
"It is recommended that NWB files using the HDF5 backend use the '.nwb' extension.", UserWarning)

if load_namespaces:
tm = get_type_map()
super().load_namespaces(tm, path, file=file_obj, driver=driver, aws_region=aws_region)
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/hdf5/test_file_copy.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
class TestFileCopy(TestCase):

def setUp(self):
self.path1 = "test_a.h5"
self.path2 = "test_b.h5"
self.path1 = "test_a.nwb"
self.path2 = "test_b.nwb"

def tearDown(self):
if os.path.exists(self.path1):
Expand Down
21 changes: 19 additions & 2 deletions tests/integration/hdf5/test_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ def setUp(self):
self.nwbfile = NWBFile(session_description='a',
identifier='b',
session_start_time=datetime(1970, 1, 1, 12, tzinfo=tzutc()))
self.path = "test_pynwb_io_hdf5_h5dataIO.h5"
self.path = "test_pynwb_io_hdf5_h5dataIO.nwb"

def tearDown(self):
remove_test_file(self.path)
Expand Down Expand Up @@ -428,7 +428,7 @@ def setUp(self):
self.nwbfile = NWBFile(session_description='a test NWB File',
identifier='TEST123',
session_start_time=datetime(1970, 1, 1, 12, tzinfo=tzutc()))
self.path = "test_pynwb_io_nwbhdf5.h5"
self.path = "test_pynwb_io_nwbhdf5.nwb"

def tearDown(self):
remove_test_file(self.path)
Expand Down Expand Up @@ -532,6 +532,23 @@ def test_round_trip_with_pathlib_path(self):
read_file = io.read()
self.assertContainerEqual(read_file, self.nwbfile)

def test_warn_for_nwb_extension(self):
"""Creating a file with an extension other than .nwb should raise a warning"""
pathlib_path = Path(self.path).with_suffix('.h5')

with self.assertWarns(UserWarning):
with NWBHDF5IO(pathlib_path, 'w') as io:
io.write(self.nwbfile)
with self.assertWarns(UserWarning):
with NWBHDF5IO(str(pathlib_path), 'w') as io:
io.write(self.nwbfile)

# should not warn on read or append
with NWBHDF5IO(str(pathlib_path), 'r') as io:
io.read()
with NWBHDF5IO(str(pathlib_path), 'a') as io:
io.read()

def test_can_read_current_nwb_file(self):
with NWBHDF5IO(self.path, 'w') as io:
io.write(self.nwbfile)
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/test_icephys_metadata_tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def setUp(self):
sweep_number=np.uint64(15)
)
self.nwbfile.add_acquisition(self.response)
self.path = 'test_icephys_meta_intracellularrecording.h5'
self.path = 'test_icephys_meta_intracellularrecording.nwb'

def tearDown(self):
remove_test_file(self.path)
Expand Down Expand Up @@ -1037,7 +1037,7 @@ class NWBFileTests(TestCase):
"""
def setUp(self):
warnings.simplefilter("always") # Trigger all warnings
self.path = 'test_icephys_meta_intracellularrecording.h5'
self.path = 'test_icephys_meta_intracellularrecording.nwb'

def tearDown(self):
remove_test_file(self.path)
Expand Down

0 comments on commit 6930a94

Please sign in to comment.