From be8be41c577c2b0942c57389a8dece92d45d4ca7 Mon Sep 17 00:00:00 2001 From: Luigi Pertoldi Date: Wed, 28 Feb 2024 14:39:51 +0100 Subject: [PATCH 1/2] [setup] restore pytest settings in pyproject.toml --- .pre-commit-config.yaml | 1 - pyproject.toml | 12 +++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 97bcb159..b8935ce3 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -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" diff --git a/pyproject.toml b/pyproject.toml index bd63e463..7ef7e489 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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"] @@ -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" From f7c4c25e1c5f0524966d1d3c19db774537de1cca Mon Sep 17 00:00:00 2001 From: Luigi Pertoldi Date: Wed, 28 Feb 2024 15:03:41 +0100 Subject: [PATCH 2/2] [docs] show deprecation warnings in docstrings --- src/lgdo/lh5_store.py | 48 +++++++++++++++++++++++++++++++++++++++++ src/lgdo/types/table.py | 5 +++++ 2 files changed, 53 insertions(+) diff --git a/src/lgdo/lh5_store.py b/src/lgdo/lh5_store.py index c6370386..1872bdca 100644 --- a/src/lgdo/lh5_store.py +++ b/src/lgdo/lh5_store.py @@ -1,3 +1,7 @@ +""" +.. warning:: + This subpackage is deprecated, use :mod:`lgdo.lh5`. +""" from __future__ import annotations import sys @@ -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], @@ -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." @@ -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." @@ -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. " @@ -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." @@ -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." @@ -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'. " @@ -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'. " @@ -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'. " @@ -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'. " diff --git a/src/lgdo/types/table.py b/src/lgdo/types/table.py index a1a5f852..2142fa60 100644 --- a/src/lgdo/types/table.py +++ b/src/lgdo/types/table.py @@ -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.