Skip to content

Commit

Permalink
Merge pull request #72 from legend-exp/dev
Browse files Browse the repository at this point in the history
Show deprecation warnings in (relevant) docstrings
  • Loading branch information
gipert authored Feb 28, 2024
2 parents 69f7bd2 + f7c4c25 commit 664881f
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 2 deletions.
1 change: 0 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ repos:
rev: "v2.2.6"
hooks:
- id: codespell
args: ["-L", "nd,unparseable,compiletime"]

- repo: https://github.com/shellcheck-py/shellcheck-py
rev: "v0.9.0.6"
Expand Down
12 changes: 11 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,6 @@ isort.required-imports = ["from __future__ import annotations"]
"tests/**" = ["T20"]
"noxfile.py" = ["T20"]


[tool.pylint]
py-version = "3.8"
ignore-paths = [".*/_version.py"]
Expand All @@ -157,3 +156,14 @@ messages_control.disable = [
"missing-module-docstring",
"wrong-import-position",
]

[tool.pytest.ini_options]
minversion = "6.0"
addopts = ["-ra", "--showlocals", "--strict-markers", "--strict-config"]
xfail_strict = true
filterwarnings = ["error", 'ignore:\nPyarrow:DeprecationWarning']
log_cli_level = "info"
testpaths = "tests"

[tool.codespell]
ignore-words-list = "nd, unparseable, compiletime"
48 changes: 48 additions & 0 deletions src/lgdo/lh5_store.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
"""
.. warning::
This subpackage is deprecated, use :mod:`lgdo.lh5`.
"""
from __future__ import annotations

import sys
Expand Down Expand Up @@ -29,6 +33,11 @@


class LH5Iterator(lh5.LH5Iterator):
"""
.. warning::
This class is deprecated, use :class:`lgdo.lh5.iterator.LH5Iterator`.
"""

def __init__(
self,
lh5_files: str | list[str],
Expand Down Expand Up @@ -70,6 +79,10 @@ def write_object(
write_start: int = 0,
**h5py_kwargs,
) -> None:
"""
.. warning::
This method is deprecated, use :meth:`lgdo.lh5.iterator.LH5Iterator.write`.
"""
warn(
"lgdo.lh5_store has moved to a subfolder lgdo.lh5 containing LH5Iterator. "
"The object you are calling this function from uses the old LH5Iterator class."
Expand Down Expand Up @@ -102,6 +115,10 @@ def read_object(
obj_buf_start: int = 0,
decompress: bool = True,
) -> tuple[LGDO, int]:
"""
.. warning::
This method is deprecated, use :meth:`lgdo.lh5.iterator.LH5Iterator.read`.
"""
warn(
"lgdo.lh5_store has moved to a subfolder lgdo.lh5 containing LH5Iterator. "
"The object you are calling this function from uses the old LH5Iterator class."
Expand All @@ -124,6 +141,11 @@ def read_object(


class LH5Store(lh5.LH5Store):
"""
.. warning::
This class is deprecated, use :class:`lgdo.lh5.iterator.LH5Store`.
"""

def __init__(self, base_path: str = "", keep_open: bool = False):
warn(
"lgdo.lh5_store has moved to a subfolder lgdo.lh5 containing LH5Store. "
Expand All @@ -140,6 +162,10 @@ def read_object(
lh5_file: str | h5py.File | list[str | h5py.File],
**kwargs,
) -> tuple[LGDO, int]:
"""
.. warning::
This method is deprecated, use :meth:`lgdo.lh5.store.LH5Store.read`.
"""
warn(
"LH5Store.read_object() has been renamed to LH5Store.read(), "
"Please update your code."
Expand All @@ -156,6 +182,10 @@ def write_object(
lh5_file: str | h5py.File,
**kwargs,
) -> tuple[LGDO, int]:
"""
.. warning::
This method is deprecated, use :meth:`lgdo.lh5.store.LH5Store.write`.
"""
warn(
"LH5Store.write_object() has been renamed to LH5Store.write(), "
"Please update your code."
Expand All @@ -172,6 +202,11 @@ def load_dfs(
lh5_group: str = "",
idx_list: list[np.ndarray | list | tuple] | None = None,
) -> pd.DataFrame:
"""
.. warning::
This function is deprecated, use :meth:`lgdo.types.lgdo.LGDO.view_as` to
view LGDO data as a Pandas data structure.
"""
warn(
"lgdo.lh5_store has moved to a subfolder lgdo.lh5. "
"Please replace 'from lgdo.lh5_store import load_dfs' with 'from lgdo.lh5 import load_dfs'. "
Expand All @@ -188,6 +223,11 @@ def load_nda(
lh5_group: str = "",
idx_list: list[np.ndarray | list | tuple] | None = None,
) -> dict[str, np.ndarray]:
"""
.. warning::
This function is deprecated, use :meth:`lgdo.types.lgdo.LGDO.view_as` to
view LGDO data as a NumPy data structure.
"""
warn(
"lgdo.lh5_store has moved to a subfolder lgdo.lh5. "
"Please replace 'from lgdo.lh5_store import load_nda' with 'from lgdo.lh5 import load_nda'. "
Expand All @@ -199,6 +239,10 @@ def load_nda(


def ls(lh5_file: str | h5py.Group, lh5_group: str = "") -> list[str]:
"""
.. warning::
This function is deprecated, import :func:`lgdo.lh5.tools.ls`.
"""
warn(
"lgdo.lh5_store has moved to a subfolder lgdo.lh5. "
"Please replace 'from lgdo.lh5_store import ls' with 'from lgdo.lh5 import ls'. "
Expand All @@ -216,6 +260,10 @@ def show(
indent: str = "",
header: bool = True,
) -> None:
"""
.. warning::
This function is deprecated, import :func:`lgdo.lh5.tools.show`.
"""
warn(
"lgdo.lh5_store has moved to a subfolder lgdo.lh5. "
"Please replace 'from lgdo.lh5_store import show' with 'from lgdo.lh5 import show'. "
Expand Down
5 changes: 5 additions & 0 deletions src/lgdo/types/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,11 @@ def get_dataframe(
) -> pd.DataFrame:
"""Get a :class:`pandas.DataFrame` from the data in the table.
Warning
-------
This method is deprecated. Use :meth:`.view_as` to view the table as a
Pandas dataframe.
Notes
-----
The requested data must be array-like, with the ``nda`` attribute.
Expand Down

0 comments on commit 664881f

Please sign in to comment.