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

Refactor sample functions to use named arguments and **kwargs #60

Closed
7 tasks done
gvegayon opened this issue Apr 3, 2024 · 1 comment · Fixed by #63
Closed
7 tasks done

Refactor sample functions to use named arguments and **kwargs #60

gvegayon opened this issue Apr 3, 2024 · 1 comment · Fixed by #63
Assignees

Comments

@gvegayon
Copy link
Member

gvegayon commented Apr 3, 2024

Goal

Following #53, we have decided to use named arguments and **kwargs for sample functions in both RandomVariable and Model.

Required features

  • Metaclasses should reflect the change.
  • So this should also be reflected in all instances.

Specifications

  • Update metaclass.py.
  • Update latent
  • Update observed
  • Update model
  • Update deterministic

Also

  • Update docstrings to reflect the change.
  • Update the tests and docs.

Example:

https://github.com/CDCgov/multisignal-epi-inference/blob/80f6a513f6acc8167958b0d098f0b5b9b7457ce0/model/src/pyrenew/latent/infections.py#L74-L98

Instead:

    def sample(
        self,
        I0_prior = None,
        **kwargs,
    ) -> tuple:
        """Samples infections given Rt


        Parameters
        ----------
        obs : random_variables, optional
            A dictionary containing an observed `Rt` sequence passed to
            `sample_infections_rt()`. It can also contain `infections` and `I0`,
            both passed to `obs` in `numpyro.sample()`.
        constants : dict
            Possible dictionary of constants.


        Returns
        -------
        InfectionsSample
            Named tuple with "infections".
        """
        I0 = npro.sample(
            name="I0",
            fn=self.I0_dist,
            obs=I0_prior,
@gvegayon gvegayon added this to the 🏰 Gargoyleosaurus milestone Apr 3, 2024
@gvegayon gvegayon self-assigned this Apr 3, 2024
@gvegayon gvegayon linked a pull request Apr 3, 2024 that will close this issue
@gvegayon
Copy link
Member Author

gvegayon commented Apr 3, 2024

@AFg6K7h4fhy2, since #47 depends on this, I've given it a stab in #63.

cc @cshelley @dylanhmorris

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant