@@ -46,14 +46,14 @@ def load_type_config(**kwargs):
4646 This method will either load the default config or the config provided by the path.
4747 """
4848 config_path = kwargs ['config_path' ]
49- type_map = kwargs ['type_map' ] or get_type_map ()
49+ type_map = kwargs ['type_map' ] or __TYPE_MAP
5050
5151 hdmf_load_type_config (config_path = config_path , type_map = type_map )
5252
5353@docval ({'name' : 'type_map' , 'type' : TypeMap , 'doc' : 'The TypeMap.' , 'default' : None },
5454 is_method = False )
5555def get_loaded_type_config (** kwargs ):
56- type_map = kwargs ['type_map' ] or get_type_map ()
56+ type_map = kwargs ['type_map' ] or __TYPE_MAP
5757 return hdmf_get_loaded_type_config (type_map = type_map )
5858
5959@docval ({'name' : 'type_map' , 'type' : TypeMap , 'doc' : 'The TypeMap.' , 'default' : None },
@@ -62,7 +62,7 @@ def unload_type_config(**kwargs):
6262 """
6363 Remove validation.
6464 """
65- type_map = kwargs ['type_map' ] or get_type_map ()
65+ type_map = kwargs ['type_map' ] or __TYPE_MAP
6666 hdmf_unload_type_config (type_map = type_map )
6767
6868def __get_resources () -> dict :
@@ -101,18 +101,28 @@ def __get_resources() -> dict:
101101@docval ({'name' : 'extensions' , 'type' : (str , TypeMap , list ),
102102 'doc' : 'a path to a namespace, a TypeMap, or a list consisting of paths to namespaces and TypeMaps' ,
103103 'default' : None },
104- returns = "TypeMap loaded for the given extension or NWB core namespace" , rtype = tuple ,
104+ {
105+ 'name' : 'copy' , 'type' : bool ,
106+ 'doc' : 'Whether to return a deepcopy of the TypeMap. '
107+ 'If False, a direct reference may be returned (use with caution).' ,
108+ 'default' : True
109+ },
110+ returns = "TypeMap loaded for the given extension or NWB core namespace" , rtype = TypeMap ,
105111 is_method = False )
106112def get_type_map (** kwargs ):
107113 '''
108114 Get the TypeMap for the given extensions. If no extensions are provided,
109115 return the TypeMap for the core namespace
110116 '''
111- extensions = getargs ('extensions' , kwargs )
117+ extensions , copy_map = getargs ('extensions' , 'copy ' , kwargs )
112118 type_map = None
113119 if extensions is None :
114- type_map = deepcopy (__TYPE_MAP )
120+ if copy_map :
121+ type_map = deepcopy (__TYPE_MAP )
122+ else :
123+ type_map = __TYPE_MAP
115124 else :
125+ warn ("The 'extensions' argument is deprecated and will be removed in PyNWB 4.0" , DeprecationWarning )
116126 if isinstance (extensions , TypeMap ):
117127 type_map = extensions
118128 else :
@@ -538,7 +548,7 @@ def read_nwb(**kwargs):
538548 # Retrieve the filepath
539549 path = popargs ('path' , kwargs )
540550 file = popargs ('file' , kwargs )
541-
551+
542552 path = str (path ) if path is not None else None
543553
544554 # Streaming case
@@ -556,18 +566,18 @@ def read_nwb(**kwargs):
556566
557567 return nwbfile
558568
559- @docval ({'name' : 'path' , 'type' : (str , Path ),
569+ @docval ({'name' : 'path' , 'type' : (str , Path ),
560570 'doc' : 'Path to the NWB file. Can be either a local filesystem path to '
561- 'an HDF5 (.nwb) or Zarr (.zarr) file.' },
571+ 'an HDF5 (.nwb) or Zarr (.zarr) file.' },
562572 is_method = False )
563573def read_nwb (** kwargs ):
564574 """Read an NWB file from a local path.
565575
566- High-level interface for reading NWB files. Automatically handles both HDF5
567- and Zarr formats. For advanced use cases (parallel I/O, custom namespaces),
576+ High-level interface for reading NWB files. Automatically handles both HDF5
577+ and Zarr formats. For advanced use cases (parallel I/O, custom namespaces),
568578 use NWBHDF5IO or NWBZarrIO.
569579
570- See also
580+ See also
571581 * :py:class:`~pynwb.NWBHDF5IO`: Core I/O class for HDF5 files with advanced options.
572582 * :py:class:`~hdmf_zarr.nwb.NWBZarrIO`: Core I/O class for Zarr files with advanced options.
573583
@@ -585,17 +595,17 @@ def read_nwb(**kwargs):
585595 * Write or append modes
586596 * Pre-opened HDF5 file objects or Zarr stores
587597 * Remote file access configuration
588-
598+
589599 Example usage reading a local NWB file:
590600
591601 .. code-block:: python
592602
593603 from pynwb import read_nwb
594- nwbfile = read_nwb("path/to/file.nwb")
604+ nwbfile = read_nwb("path/to/file.nwb")
595605
596606 :Returns: pynwb.NWBFile The loaded NWB file object.
597607 """
598-
608+
599609 path = popargs ('path' , kwargs )
600610 # HDF5 is always available so we try that first
601611 backend_is_hdf5 = NWBHDF5IO .can_read (path = path )
@@ -607,18 +617,18 @@ def read_nwb(**kwargs):
607617 from hdmf_zarr import NWBZarrIO
608618 backend_is_zarr = NWBZarrIO .can_read (path = path )
609619 if backend_is_zarr :
610- return NWBZarrIO .read_nwb (path = path )
620+ return NWBZarrIO .read_nwb (path = path )
611621 else :
612622 raise ValueError (
613623 f"Unable to read file: '{ path } '. The file is not recognized as "
614624 "either a valid HDF5 or Zarr NWB file. Please ensure the file exists and contains valid NWB data."
615- )
625+ )
616626 except ImportError :
617627 raise ValueError (
618628 f"Unable to read file: '{ path } '. The file is not recognized as an HDF5 NWB file. "
619629 "If you are trying to read a Zarr file, please install hdmf-zarr using: pip install hdmf-zarr"
620630 )
621-
631+
622632
623633
624634from . import io as __io # noqa: F401,E402
@@ -642,7 +652,7 @@ def read_nwb(**kwargs):
642652 # Functions
643653 'get_type_map' ,
644654 'get_manager' ,
645- 'load_namespaces' ,
655+ 'load_namespaces' ,
646656 'available_namespaces' ,
647657 'clear_cache_dir' ,
648658 'register_class' ,
@@ -653,11 +663,11 @@ def read_nwb(**kwargs):
653663 'unload_type_config' ,
654664 'read_nwb' ,
655665 'get_nwbfile_version' ,
656-
666+
657667 # Classes
658668 'NWBHDF5IO' ,
659669 'NWBContainer' ,
660- 'NWBData' ,
670+ 'NWBData' ,
661671 'TimeSeries' ,
662672 'ProcessingModule' ,
663673 'NWBFile' ,
0 commit comments