Skip to content

change var to variable #512

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 10, 2025
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
8 changes: 4 additions & 4 deletions pymc_extras/prior.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ def create_variable(self, name: str) -> pt.TensorVariable:
def sample_prior(
factory: VariableFactory,
coords=None,
name: str = "var",
name: str = "variable",
wrap: bool = False,
**sample_prior_predictive_kwargs,
) -> xr.Dataset:
Expand All @@ -292,7 +292,7 @@ def sample_prior(
The coordinates for the variable, by default None.
Only required if the dims are specified.
name : str, optional
The name of the variable, by default "var".
The name of the variable, by default "variable".
wrap : bool, optional
Whether to wrap the variable in a `pm.Deterministic` node, by default False.
sample_prior_predictive_kwargs : dict
Expand Down Expand Up @@ -900,7 +900,7 @@ def __eq__(self, other) -> bool:
def sample_prior(
self,
coords=None,
name: str = "var",
name: str = "variable",
**sample_prior_predictive_kwargs,
) -> xr.Dataset:
"""Sample the prior distribution for the variable.
Expand All @@ -911,7 +911,7 @@ def sample_prior(
The coordinates for the variable, by default None.
Only required if the dims are specified.
name : str, optional
The name of the variable, by default "var".
The name of the variable, by default "variable".
sample_prior_predictive_kwargs : dict
Additional arguments to pass to `pm.sample_prior_predictive`.

Expand Down
14 changes: 10 additions & 4 deletions tests/test_prior.py
Original file line number Diff line number Diff line change
Expand Up @@ -616,7 +616,10 @@ def test_custom_transform() -> None:
prior = dist.sample_prior(draws=10)
df_prior = prior.to_dataframe()

np.testing.assert_array_equal(df_prior["var"].to_numpy(), df_prior["var_raw"].to_numpy() ** 2)
np.testing.assert_array_equal(
df_prior.variable.to_numpy(),
df_prior.variable_raw.to_numpy() ** 2,
)


def test_custom_transform_comes_first() -> None:
Expand All @@ -627,7 +630,10 @@ def test_custom_transform_comes_first() -> None:
prior = dist.sample_prior(draws=10)
df_prior = prior.to_dataframe()

np.testing.assert_array_equal(df_prior["var"].to_numpy(), 2 * df_prior["var_raw"].to_numpy())
np.testing.assert_array_equal(
df_prior.variable.to_numpy(),
2 * df_prior.variable_raw.to_numpy(),
)

clear_custom_transforms()

Expand Down Expand Up @@ -686,7 +692,7 @@ def test_sample_prior_arbitrary_no_name() -> None:
prior = sample_prior(var, coords={"channel": ["A", "B", "C"]}, draws=25)

assert isinstance(prior, xr.Dataset)
assert "var" not in prior
assert "variable" not in prior

prior_with = sample_prior(
var,
Expand All @@ -696,7 +702,7 @@ def test_sample_prior_arbitrary_no_name() -> None:
)

assert isinstance(prior_with, xr.Dataset)
assert "var" in prior_with
assert "variable" in prior_with


def test_create_prior_with_arbitrary() -> None:
Expand Down