-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add NWBZarrIO.read_nwb convenience function #226
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
cca7b20
Fix #225 Add NWBZarrIO.read_nwb convenience function
oruebel b153da0
Update Changelog
oruebel 8062b05
Fix ruff
oruebel 82b74c2
Remove broken test
oruebel 44b036d
Remove extra skip on unittest
oruebel f76889d
Fix import in unit test
oruebel 4c6f9dc
Fix extra arg in unittest
oruebel 2d7b77f
Fix asset in unit test
oruebel 79f90e1
replace file
mavaylon1 f472a12
Merge branch 'dev' into add/read_nwb_func
oruebel db60493
Merge branch 'dev' into add/read_nwb_func
oruebel File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import unittest | ||
from hdmf_zarr import NWBZarrIO | ||
import os | ||
import shutil | ||
from datetime import datetime | ||
from dateutil.tz import tzlocal | ||
|
||
try: | ||
from pynwb import NWBFile | ||
PYNWB_AVAILABLE = True | ||
except ImportError: | ||
PYNWB_AVAILABLE = False | ||
|
||
|
||
@unittest.skipIf(not PYNWB_AVAILABLE, "PyNWB not installed") | ||
class TestNWBZarrIO(unittest.TestCase): | ||
|
||
def setUp(self): | ||
self.filepath = "test_io.zarr" | ||
|
||
def tearDown(self): | ||
if os.path.exists(self.filepath): | ||
shutil.rmtree(self.filepath) | ||
|
||
def write_test_file(self): | ||
# Create the NWBFile | ||
nwbfile = NWBFile( | ||
session_description="my first synthetic recording", | ||
identifier="EXAMPLE_ID", | ||
session_start_time=datetime.now(tzlocal()), | ||
experimenter="Dr. Bilbo Baggins", | ||
lab="Bag End Laboratory", | ||
institution="University of Middle Earth at the Shire", | ||
experiment_description="I went on an adventure with thirteen dwarves " | ||
"to reclaim vast treasures.", | ||
session_id="LONELYMTN", | ||
) | ||
|
||
# Create a device | ||
_ = nwbfile.create_device( | ||
name="array", description="the best array", manufacturer="Probe Company 9000" | ||
) | ||
with NWBZarrIO(path=self.filepath, mode="w") as io: | ||
io.write(nwbfile) | ||
|
||
def test_read_nwb(self): | ||
""" | ||
Test reading a local file with NWBZarrIO.read_nwb. | ||
|
||
NOTE: See TestFSSpecStreaming.test_fsspec_streaming_via_read_nwb for corresponding tests | ||
for reading a remote file with NWBZarrIO.read_nwb | ||
""" | ||
self.write_test_file() | ||
nwbfile = NWBZarrIO.read_nwb(path=self.filepath) | ||
self.assertEqual(len(nwbfile.devices), 1) | ||
self.assertTupleEqual(nwbfile.experimenter, ('Dr. Bilbo Baggins',)) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mavaylon1, was this released already? it is on the changelog on the 0.9.0 release but the PR was merged a week ago. Is that a changelog error?