Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 1 addition & 2 deletions docs/quickstart_for_tidybayes_users.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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`][].
Expand Down
4 changes: 2 additions & 2 deletions polarbayes/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
]
4 changes: 1 addition & 3 deletions polarbayes/gather.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion polarbayes/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion polarbayes/spread.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Iterable
from collections.abc import Iterable

import arviz_base as az
import numpy as np
Expand Down
2 changes: 1 addition & 1 deletion test/test_gather.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
7 changes: 3 additions & 4 deletions test/test_spread.py
Original file line number Diff line number Diff line change
@@ -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")
Expand Down
Loading