From cff1f6ec82e1b1b673ff65e83747ada17f076e77 Mon Sep 17 00:00:00 2001 From: Ben Dichter Date: Tue, 30 Jan 2024 17:15:20 -0500 Subject: [PATCH] fixing up tutorial --- docs/gallery/advanced_io/plot_editing.py | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/docs/gallery/advanced_io/plot_editing.py b/docs/gallery/advanced_io/plot_editing.py index e74b69fdf..a7dd0d244 100644 --- a/docs/gallery/advanced_io/plot_editing.py +++ b/docs/gallery/advanced_io/plot_editing.py @@ -7,7 +7,7 @@ common types of edits for HDF5 files. Keep in mind that any edit to an existing NWB file make it no longer a valid NWB file. We call this "doing surgery" on the NWB file. We highly recommend making a copy before editing and running a validation check on the -file after editing it. +file after editing it. See :ref:`validating`. In-place editing with h5py --------------------------- @@ -69,19 +69,24 @@ ############################################## # .. warning:: # You can edit values that will bring the file out of compliance with -# the NWB specification. For example: -# -# with h5py.File("test_edit.nwb", "r+") as f: -# f["acquisition"]["synthetic_timeseries"]["neurodata_type"] = "TimeSeries" +# the NWB specification. # # Renaming groups and datasets # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # Rename groups and datasets in-place using the ``move`` method. For example, to rename # the ``"synthetic_timeseries"`` group: -with h5py.File("test_edit2.nwb", "r+") as f: +with h5py.File("test_edit.nwb", "r+") as f: f["acquisition"].move("synthetic_timeseries", "synthetic_timeseries_renamed") +############################################## +# You can use this same technique to move a group or dataset to a different location in +# the file. For example, to move the ``"synthetic_timeseries_renamed"`` group to the +# ``"analysis"`` group: + +with h5py.File("test_edit.nwb", "r+") as f: + f["acquisition"].move("synthetic_timeseries_renamed", "/analysis/synthetic_timeseries_renamed") + ############################################## # Changing the shape of dataset # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -91,7 +96,7 @@ # ``maxshape`` argument of the :py:class:`~hdmf.backends.hdf5.h5_utils.H5DataIO` class # constructor. Using a ``None`` value for ``maxshape`` allows the dataset to be reset # arbitrarily long in that dimension. Chunking is required for datasets with flexible -# shapes. Setting ``maxshape`` automatically sets chunking to ``True`, if not specified. +# shapes. Setting ``maxshape`` automatically sets chunking to ``True``, if not specified. # # First, let's create an NWB file with a dataset with a flexible shape: