From 5e8ddc289d93b710939ade6768d65b57540a9348 Mon Sep 17 00:00:00 2001 From: Ben Dichter Date: Mon, 27 Nov 2023 21:10:51 +0100 Subject: [PATCH] Docs rmv load namespaces (#1792) * rmv unnecessary load_namespaces from gallery * fix extensions.py to reflect new default --- docs/gallery/advanced_io/streaming.py | 4 ++-- docs/gallery/general/extensions.py | 15 +++++---------- docs/gallery/general/plot_read_basics.py | 4 ++-- 3 files changed, 9 insertions(+), 14 deletions(-) diff --git a/docs/gallery/advanced_io/streaming.py b/docs/gallery/advanced_io/streaming.py index bb5c2e1d8..fb34b498b 100644 --- a/docs/gallery/advanced_io/streaming.py +++ b/docs/gallery/advanced_io/streaming.py @@ -69,7 +69,7 @@ # next, open the file with fs.open(s3_url, "rb") as f: with h5py.File(f) as file: - with pynwb.NWBHDF5IO(file=file, load_namespaces=True) as io: + with pynwb.NWBHDF5IO(file=file) as io: nwbfile = io.read() print(nwbfile.acquisition['lick_times'].time_series['lick_left_times'].data[:]) @@ -99,7 +99,7 @@ from pynwb import NWBHDF5IO -with NWBHDF5IO(s3_url, mode='r', load_namespaces=True, driver='ros3') as io: +with NWBHDF5IO(s3_url, mode='r', driver='ros3') as io: nwbfile = io.read() print(nwbfile) print(nwbfile.acquisition['lick_times'].time_series['lick_left_times'].data[:]) diff --git a/docs/gallery/general/extensions.py b/docs/gallery/general/extensions.py index 5140c531b..66645a660 100644 --- a/docs/gallery/general/extensions.py +++ b/docs/gallery/general/extensions.py @@ -248,16 +248,11 @@ def __init__(self, **kwargs): # .. note:: # # For more information on writing NWB files, see :ref:`basic_writing`. - -#################### -# By default, PyNWB does not use the namespaces cached in a file--you must -# explicitly specify this. This behavior is enabled by the *load_namespaces* -# argument to the :py:class:`~pynwb.NWBHDF5IO` constructor. - -with NWBHDF5IO("cache_spec_example.nwb", mode="r") as io: - nwbfile = io.read() - -#################### +# +# By default, if a namespace is not already loaded, PyNWB loads the namespace cached in +# the file. To disable this, set ``load_namespaces=False`` in the +# :py:class:`~pynwb.NWBHDF5IO` constructor. +# # .. _MultiContainerInterface: # # Creating and using a custom MultiContainerInterface diff --git a/docs/gallery/general/plot_read_basics.py b/docs/gallery/general/plot_read_basics.py index bba380092..c4a829d75 100644 --- a/docs/gallery/general/plot_read_basics.py +++ b/docs/gallery/general/plot_read_basics.py @@ -104,14 +104,14 @@ filepath = "sub-P11HMH_ses-20061101_ecephys+image.nwb" # Open the file in read mode "r", -io = NWBHDF5IO(filepath, mode="r", load_namespaces=True) +io = NWBHDF5IO(filepath, mode="r") nwbfile = io.read() nwbfile ####################################### # :py:class:`~pynwb.NWBHDF5IO` can also be used as a context manager: -with NWBHDF5IO(filepath, mode="r", load_namespaces=True) as io2: +with NWBHDF5IO(filepath, mode="r") as io2: nwbfile2 = io2.read() # data accessible here