Skip to content

Commit

Permalink
build doc
Browse files Browse the repository at this point in the history
  • Loading branch information
mavaylon1 committed Sep 22, 2023
1 parent 1a4cb28 commit c1b4dba
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions docs/gallery/plot_convert_nwb_hdf5.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@

import os
import shutil
from pynwb import NWBHDF5IO
from hdmf_zarr.nwb import NWBZarrIO
from contextlib import suppress

# Input file to convert
basedir = "resources"
Expand All @@ -38,9 +41,6 @@
# As this is an NWB file, we here use the :py:class:`pynwb.NWBHDF5IO` backend for reading the file from
# from HDF5 and use the :py:class:`~hdmf_zarr.nwb.NWBZarrIO` backend to export the file to Zarr.

from pynwb import NWBHDF5IO
from hdmf_zarr.nwb import NWBZarrIO

with NWBHDF5IO(filename, 'r', load_namespaces=False) as read_io: # Create HDF5 IO object for read
with NWBZarrIO(zarr_filename, mode='w') as export_io: # Create Zarr IO object for write
export_io.export(src_io=read_io, write_args=dict(link_data=False)) # Export from HDF5 to Zarr
Expand All @@ -53,7 +53,6 @@
#
# Read the Zarr file back in
# --------------------------
#

zr = NWBZarrIO(zarr_filename, 'r')
zf = zr.read()
Expand Down Expand Up @@ -82,7 +81,7 @@
# ----------------------------------
#
# Using the same approach as above, we can now convert our Zarr file back to HDF5.
try: # TODO: This is a temporary ignore on the convert_dtype exception.
with suppress(Exception): # TODO: This is a temporary ignore on the convert_dtype exception.
with NWBZarrIO(zarr_filename, mode='r') as read_io: # Create Zarr IO object for read
with NWBHDF5IO(hdf_filename, 'w') as export_io: # Create HDF5 IO object for write
export_io.export(src_io=read_io, write_args=dict(link_data=False)) # Export from Zarr to HDF5
Expand All @@ -93,9 +92,6 @@
#
# Now our file has been converted from HDF5 to Zarr and back again to HDF5.
# Here we check that we can still read that file.

with suppress(Exception): # TODO: This is a temporary ignore on the convert_dtype exception.
with NWBHDF5IO(hdf_filename, 'r') as hr:
hf = hr.read()

except Exception:
pass

0 comments on commit c1b4dba

Please sign in to comment.