diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index e873a16..3f205a1 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -11,13 +11,13 @@ repos: - id: trailing-whitespace # Python - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.15.20 + rev: v0.16.6 hooks: # lint - id: ruff-check # format - id: ruff-format - repo: https://github.com/astral-sh/uv-pre-commit - rev: 0.11.25 + rev: 0.12.10 hooks: - id: uv-lock diff --git a/docs/quickstart_for_tidybayes_users.md b/docs/quickstart_for_tidybayes_users.md index 868b727..caad1c4 100644 --- a/docs/quickstart_for_tidybayes_users.md +++ b/docs/quickstart_for_tidybayes_users.md @@ -13,7 +13,6 @@ import polarbayes as pb pb.spread_draws(data, var_names=["var1", "var2"]) pb.gather_draws(data, var_names=["var1", "var2"]) - ``` Or provide no `var_names` to spread or gather all available variables: @@ -58,7 +57,7 @@ draws <- mcmc_output |> spread_draws(x1[time], x2[time, location]) might become this PolarBayes Python code: ```python -draws = pb.spread_draws(mcmc_output_arviz, var_names = ["x1", "x2"]) +draws = pb.spread_draws(mcmc_output_arviz, var_names=["x1", "x2"]) ``` The PolarBayes output will still have `time` and `location` columns along with the MCMC sample ID columns, provided those are the names of the dimensions in the `mcmc_output_arviz` [`xarray.DataTree`][] object. If the dimension names in your [`xarray.DataTree`][] object are not the ones you want in your output data frame, you can simply rename them via [`polars.DataFrame.rename`][]. diff --git a/polarbayes/__init__.py b/polarbayes/__init__.py index cf3b685..6c8b120 100644 --- a/polarbayes/__init__.py +++ b/polarbayes/__init__.py @@ -2,8 +2,8 @@ from polarbayes.spread import spread_draws, spread_draws_and_get_index_cols __all__ = [ + "gather_draws", + "gather_variables", "spread_draws", "spread_draws_and_get_index_cols", - "gather_variables", - "gather_draws", ] diff --git a/polarbayes/gather.py b/polarbayes/gather.py index 21406e9..120f956 100644 --- a/polarbayes/gather.py +++ b/polarbayes/gather.py @@ -1,5 +1,4 @@ -from collections.abc import Sequence -from typing import Iterable +from collections.abc import Iterable, Sequence import arviz_base as az import numpy as np @@ -51,7 +50,6 @@ def _assert_not_in_index_columns( f"in the input data frame. Either specify a different " f" {arg_name} or rename the index column named '{arg_value}'." ) - return None def gather_variables( diff --git a/polarbayes/schema.py b/polarbayes/schema.py index 12bf18e..ae15533 100644 --- a/polarbayes/schema.py +++ b/polarbayes/schema.py @@ -2,7 +2,7 @@ Column order schemas for polarbayes output """ -from typing import Iterable +from collections.abc import Iterable # default and reserved column names CHAIN_NAME = "chain" diff --git a/polarbayes/spread.py b/polarbayes/spread.py index 2b7300c..360927e 100644 --- a/polarbayes/spread.py +++ b/polarbayes/spread.py @@ -1,4 +1,4 @@ -from typing import Iterable +from collections.abc import Iterable import arviz_base as az import numpy as np diff --git a/test/test_gather.py b/test/test_gather.py index 6b14da6..f05b91f 100644 --- a/test/test_gather.py +++ b/test/test_gather.py @@ -7,9 +7,9 @@ import pytest from polarbayes.gather import ( + _assert_not_in_index_columns, gather_draws, gather_variables, - _assert_not_in_index_columns, ) from polarbayes.schema import CHAIN_NAME, DRAW_NAME, VALUE_NAME, VARIABLE_NAME diff --git a/test/test_spread.py b/test/test_spread.py index 6cd3e17..279c47e 100644 --- a/test/test_spread.py +++ b/test/test_spread.py @@ -1,16 +1,15 @@ import arviz_base as az import numpy as np -import pytest import pandas as pd import polars as pl import polars.selectors as cs +import pytest -from polarbayes.schema import order_index_column_names, CHAIN_NAME, DRAW_NAME - +from polarbayes.schema import CHAIN_NAME, DRAW_NAME, order_index_column_names from polarbayes.spread import ( - spread_draws_to_pandas_, spread_draws, spread_draws_and_get_index_cols, + spread_draws_to_pandas_, ) eight_schools_data = az.load_arviz_data("non_centered_eight")