Skip to content
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

Fourier class sample_prior support for non-Prior classes #1343

Open
wd60622 opened this issue Jan 4, 2025 · 0 comments
Open

Fourier class sample_prior support for non-Prior classes #1343

wd60622 opened this issue Jan 4, 2025 · 0 comments
Labels
bug Something isn't working MMM

Comments

@wd60622
Copy link
Contributor

wd60622 commented Jan 4, 2025

Having sample_prior method is not requirement of VariableFactory, only Prior so this needs to be changed:

def sample_prior(self, coords: dict | None = None, **kwargs) -> xr.Dataset:
"""Sample the prior distributions.
Parameters
----------
coords : dict, optional
Coordinates for the prior distribution, by default None
kwargs
Additional keywords for sample_prior_predictive
Returns
-------
xr.Dataset
Prior distribution.
"""
coords = coords or {}
coords[self.prefix] = self.nodes
return self.prior.sample_prior(coords=coords, name=self.variable_name, **kwargs)

Something like in the media transformations will have to be done in order to support non-Prior classes:

def sample_prior(
self, coords: dict | None = None, **sample_prior_predictive_kwargs
) -> xr.Dataset:
"""Sample the priors for the transformation.
Parameters
----------
coords : dict, optional
The coordinates for the associated with dims
**sample_prior_predictive_kwargs
Keyword arguments for the pm.sample_prior_predictive function.
Returns
-------
xr.Dataset
The dataset with the sampled priors.
"""
coords = coords or {}
dims = tuple(coords.keys())
with pm.Model(coords=coords):
self._create_distributions(dims=dims)
return pm.sample_prior_predictive(**sample_prior_predictive_kwargs).prior

@wd60622 wd60622 added bug Something isn't working MMM and removed Needs Triage labels Jan 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working MMM
Projects
None yet
Development

No branches or pull requests

1 participant