Open aflaxman opened 1 year ago
Can you post your example? The safer option may be to coerce the scalar to a series
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.
I tried using a float for a simple example and found that the rate variable uses
rate[rate>250]
pattern now:https://github.com/ihmeuw/vivarium/blob/262c48bcbffb96e9e8496200bc990eec85baf6c0/src/vivarium/framework/utilities.py#L29
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.