Skip to content

Commit

Permalink
Merge branch 'dev' into update-versioning-from-VCS
Browse files Browse the repository at this point in the history
  • Loading branch information
stephprince authored Dec 19, 2023
2 parents ea61fa4 + dd2e848 commit 3908279
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
- Add `NWBHDF5IO.can_read()`. @bendichter [#1703](https://github.com/NeurodataWithoutBorders/pynwb/pull/1703)
- Add `pynwb.get_nwbfile_version()`. @bendichter [#1703](https://github.com/NeurodataWithoutBorders/pynwb/pull/1703)
- Updated timeseries data checks to warn instead of error when reading invalid files. @stephprince [#1793](https://github.com/NeurodataWithoutBorders/pynwb/pull/1793)
- Expose the offset, conversion and channel conversion parameters in `mock_ElectricalSeries`. @h-mayorquin [#1796](https://github.com/NeurodataWithoutBorders/pynwb/pull/1796)

### Bug fixes
- Fix bug where namespaces were loaded in "w-" mode. @h-mayorquin [#1795](https://github.com/NeurodataWithoutBorders/pynwb/pull/1795)

## PyNWB 2.5.0 (August 18, 2023)

Expand Down
3 changes: 2 additions & 1 deletion src/pynwb/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,8 @@ def __init__(self, **kwargs):
popargs('path', 'mode', 'manager', 'extensions', 'load_namespaces',
'file', 'comm', 'driver', 'herd_path', kwargs)
# Define the BuildManager to use
if mode in 'wx' or manager is not None or extensions is not None:
io_modes_that_create_file = ['w', 'w-', 'x']
if mode in io_modes_that_create_file or manager is not None or extensions is not None:
load_namespaces = False

if load_namespaces:
Expand Down
8 changes: 7 additions & 1 deletion src/pynwb/testing/mock/ecephys.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,10 @@ def mock_ElectricalSeries(
timestamps=None,
electrodes: Optional[DynamicTableRegion] = None,
filtering: str = "filtering",
nwbfile: Optional[NWBFile] = None
nwbfile: Optional[NWBFile] = None,
channel_conversion: Optional[np.ndarray] = None,
conversion: float = 1.0,
offset: float = 0.,
) -> ElectricalSeries:
electrical_series = ElectricalSeries(
name=name or name_generator("ElectricalSeries"),
Expand All @@ -83,6 +86,9 @@ def mock_ElectricalSeries(
timestamps=timestamps,
electrodes=electrodes or mock_electrodes(nwbfile=nwbfile),
filtering=filtering,
conversion=conversion,
offset=offset,
channel_conversion=channel_conversion,
)

if nwbfile is not None:
Expand Down
15 changes: 15 additions & 0 deletions tests/integration/hdf5/test_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import numpy as np
from h5py import File
from pathlib import Path
import tempfile

from pynwb import NWBFile, TimeSeries, get_manager, NWBHDF5IO, validate

Expand All @@ -14,6 +15,7 @@
from pynwb.spec import NWBGroupSpec, NWBDatasetSpec, NWBNamespace
from pynwb.ecephys import ElectricalSeries, LFP
from pynwb.testing import remove_test_file, TestCase
from pynwb.testing.mock.file import mock_NWBFile


class TestHDF5Writer(TestCase):
Expand Down Expand Up @@ -122,6 +124,19 @@ def test_write_no_cache_spec(self):
with File(self.path, 'r') as f:
self.assertNotIn('specifications', f)

def test_file_creation_io_modes(self):
io_modes_that_create_file = ["w", "w-", "x"]

with tempfile.TemporaryDirectory() as temp_dir:
temp_dir = Path(temp_dir)
for io_mode in io_modes_that_create_file:
file_path = temp_dir / f"test_io_mode={io_mode}.nwb"

# Test file creation
nwbfile = mock_NWBFile()
with NWBHDF5IO(str(file_path), io_mode) as io:
io.write(nwbfile)


class TestHDF5WriterWithInjectedFile(TestCase):

Expand Down

0 comments on commit 3908279

Please sign in to comment.