-
Notifications
You must be signed in to change notification settings - Fork 247
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
excluded _prior suffix from CLV models #1498
base: main
Are you sure you want to change the base?
Changes from all commits
9dae3de
2bbad87
fa32027
42d0bc8
f1d9f8f
bcb8470
dcb6e67
c65e12f
65a5940
cd87a0a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,6 +47,19 @@ | |
non_distributions: list[str] | None = None, | ||
): | ||
model_config = model_config or {} | ||
|
||
deprecated_keys = [key for key in model_config if key.endswith("_prior")] | ||
for key in deprecated_keys: | ||
new_key = key.replace("_prior", "") | ||
warnings.warn( | ||
f"The key '{key}' in model_config is deprecated and will be removed in future versions." | ||
f"Use '{new_key}' instead.", | ||
DeprecationWarning, | ||
stacklevel=2, | ||
) | ||
|
||
model_config[new_key] = model_config.pop(key) | ||
|
||
model_config = parse_model_config( | ||
model_config, | ||
non_distributions=non_distributions, | ||
|
@@ -279,12 +292,28 @@ | |
model_config=json.loads(idata.attrs["model_config"]), # type: ignore | ||
sampler_config=json.loads(idata.attrs["sampler_config"]), | ||
) | ||
|
||
model.idata = idata | ||
model._rename_posterior_variables() | ||
|
||
model.build_model() # type: ignore | ||
if model.id != idata.attrs["id"]: | ||
raise ValueError(f"Inference data not compatible with {cls._model_type}") | ||
return model | ||
|
||
def _rename_posterior_variables(self): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's add a TODO to remove this in a future release. I'd say 2025-Q4 or early 2026 will give users enough time to update their codebases. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's do an issue instead 🙏 |
||
"""Rename variables in the posterior group to remove the _prior suffix. | ||
|
||
This is used to support the old model configuration format, which used | ||
to include a _prior suffix for each parameter. | ||
""" | ||
prior_vars = [ | ||
var for var in self.idata.posterior.data_vars if var.endswith("_prior") | ||
] | ||
rename_dict = {var: var.replace("_prior", "") for var in prior_vars} | ||
self.idata.posterior = self.idata.posterior.rename(rename_dict) | ||
return self.idata.posterior | ||
|
||
def thin_fit_result(self, keep_every: int): | ||
"""Return a copy of the model with a thinned fit result. | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's add a TODO to remove these codelines in a future release. I'd say 2025-Q4 or early 2026 will give users enough time to update their codebases.