diff --git a/src/lgdo/__init__.py b/src/lgdo/__init__.py index 274b9bdd..cf323647 100644 --- a/src/lgdo/__init__.py +++ b/src/lgdo/__init__.py @@ -39,11 +39,8 @@ """ from ._version import version as __version__ - -# from .lh5 import Iterator, Store, load_dfs, load_nda, ls, show from .lh5 import Iterator, Store, load_dfs, load_nda, ls, show - -# from .lh5_store import LH5Iterator, LH5Store +from .lh5_store import LH5Iterator, LH5Store from .types import ( LGDO, Array, @@ -76,7 +73,7 @@ "load_nda", "ls", "show", - # "LH5Iterator", - # "LH5Store" + "LH5Iterator", + "LH5Store", "__version__", ] diff --git a/src/lgdo/lgdo_utils.py b/src/lgdo/lgdo_utils.py index 13fa52a6..a6444d7f 100644 --- a/src/lgdo/lgdo_utils.py +++ b/src/lgdo/lgdo_utils.py @@ -4,20 +4,24 @@ from .lh5 import utils -warn( - "lgdo.lh5_store has moved to a subfolder lgdo.lh5 containing Store and Iterator. " - "Please replace 'import lgdo.lh5_store' with 'import lgdo.lh5'. " - "lgdo.lh5_store will be removed in a future release.", - DeprecationWarning, - stacklevel=2, -) + +def throw_dep_warning(): + warn( + "lgdo.lh5_store has moved to a subfolder lgdo.lh5 containing Store and Iterator. " + "Please replace 'import lgdo.lh5_store' with 'import lgdo.lh5'. " + "lgdo.lh5_store will be removed in a future release.", + DeprecationWarning, + stacklevel=2, + ) def parse_datatype(datatype: str) -> tuple[str, tuple[int, ...], str | list[str]]: + throw_dep_warning() return utils.parse_datatype(datatype) def expand_vars(expr: str, substitute: dict[str, str] = None) -> str: + throw_dep_warning() return utils.expand_vars(expr, substitute) @@ -27,4 +31,5 @@ def expand_path( list: bool = False, base_path: str = None, ) -> str | list: + throw_dep_warning() return utils.expand_path(path, substitute, list, base_path) diff --git a/src/lgdo/lh5_store.py b/src/lgdo/lh5_store.py index 26a2157e..3de2769a 100644 --- a/src/lgdo/lh5_store.py +++ b/src/lgdo/lh5_store.py @@ -22,15 +22,17 @@ DEFAULT_HDF5_COMPRESSION = None -class LH5Iterator(lh5.Iterator): +def throw_dep_warning(): warn( "lgdo.lh5_store has moved to a subfolder lgdo.lh5 containing Store and Iterator. " - "Please replace 'from lgdo.lh5_store import LH5Iterator' with 'from lgdo.lh5 import Iterator'. " + "Please replace 'import lgdo.lh5_store' with 'import lgdo.lh5'. " "lgdo.lh5_store will be removed in a future release.", DeprecationWarning, stacklevel=2, ) + +class LH5Iterator(lh5.Iterator): def __init__( self, lh5_files: str | list[str], @@ -42,6 +44,7 @@ def __init__( buffer_len: int = 3200, friend: Iterator = None, ) -> None: + throw_dep_warning() super().__init__( lh5_files, groups, @@ -55,15 +58,8 @@ def __init__( class LH5Store(lh5.Store): - warn( - "lgdo.lh5_store has moved to a subfolder lgdo.lh5 containing Store and Iterator. " - "Please replace 'from lgdo.lh5_store import LH5Store' with 'from lgdo.lh5 import Store'. " - "lgdo.lh5_store will be removed in a future release.", - DeprecationWarning, - stacklevel=2, - ) - def __init__(self, base_path: str = "", keep_open: bool = False): + throw_dep_warning() super().__init__(base_path, keep_open) @@ -73,6 +69,7 @@ def load_dfs( lh5_group: str = "", idx_list: list[np.ndarray | list | tuple] = None, ) -> pd.DataFrame: + throw_dep_warning() return lh5.load_dfs(f_list, par_list, lh5_group, idx_list) @@ -82,10 +79,12 @@ def load_nda( lh5_group: str = "", idx_list: list[np.ndarray | list | tuple] = None, ) -> dict[str, np.ndarray]: + throw_dep_warning() return lh5.load_nda(f_list, par_list, lh5_group, idx_list) def ls(lh5_file: str | h5py.Group, lh5_group: str = "") -> list[str]: + throw_dep_warning() return lh5.ls(lh5_file, lh5_group) @@ -96,4 +95,5 @@ def show( indent: str = "", header: bool = True, ) -> None: + throw_dep_warning() show(lh5_file, lh5_group, attrs, indent, header)