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

Fix failing test test_inverse_prop #336

Closed
drbenvincent opened this issue May 7, 2024 · 1 comment
Closed

Fix failing test test_inverse_prop #336

drbenvincent opened this issue May 7, 2024 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@drbenvincent
Copy link
Collaborator

drbenvincent commented May 7, 2024

Slightly strange because all tests passed for #311. But we have a failing remote test for https://github.com/pymc-labs/CausalPy/actions/runs/8974649334/job/24647471387

On main I re-built the environment from scratch following instructions in CONTRIBUTING.md and can reproduce this bug locally:

FAILED causalpy/tests/test_pymc_experiments.py::test_inverse_prop - ValueError: autodetected range of [nan, nan] is not finite

This was fixed by adding in the rand_seed code to the PropensityScore.fit method which overrides the ModelBuilder.fit method. So the method should now be:

def fit(self, X, t, coords):
    """Draw samples from posterior, prior predictive, and posterior predictive
    distributions. We overwrite the base method because the base method assumes
    a variable y and we use t to indicate the treatment variable here.
    """

    # Ensure random_seed is used in sample_prior_predictive() and
    # sample_posterior_predictive() if provided in sample_kwargs.
    random_seed = self.sample_kwargs.get("random_seed", None)

    self.build_model(X, t, coords)
    with self:
        self.idata = pm.sample(**self.sample_kwargs)
        self.idata.extend(pm.sample_prior_predictive(random_seed=random_seed))
        self.idata.extend(
            pm.sample_posterior_predictive(
                self.idata, progressbar=False, random_seed=random_seed
            )
        )
    return self.idata

Though it's worth double checking the details of the test and error message which I didn't do 🤷🏻‍♂️😜

@drbenvincent
Copy link
Collaborator Author

closed by #337

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants