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

Possible Bug: is rate required to be a pd.Series in framework.utilities.rate_to_probability? #257

Open
aflaxman opened this issue Dec 31, 2022 · 2 comments

Comments

@aflaxman
Copy link
Member

I tried using a float for a simple example and found that the rate variable uses rate[rate>250] pattern now:

rate[rate > 250] = 250.0

I would like to change this to np.clip(rate, -np.inf, 250.0), so that it works with scalars, but I thought I'd see if anyone sees a risk in this before making a PR.

@collijk
Copy link
Member

collijk commented Feb 21, 2023

Can you post your example? The safer option may be to coerce the scalar to a series

@aflaxman
Copy link
Member Author

Here is a code snippet that shows where I ran into the issue

    def on_time_step(self, event):
        population = self.population_view.get(
            event.index, query='alive == "alive" and sex =="Female" and age >= 15 and age < 45'
        )
        had_children = self.randomness.filter_for_rate(population, (2.5/30/365) # FIXME: float does not work here

Here is a notebook that puts this in context. Cell 6 shows how this fails, and Cell 7 shows a simple work-around.

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

No branches or pull requests

2 participants