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

Data types in demographic inputs #751

Open
daniel-klein opened this issue Nov 8, 2024 · 0 comments
Open

Data types in demographic inputs #751

daniel-klein opened this issue Nov 8, 2024 · 0 comments
Milestone

Comments

@daniel-klein
Copy link
Contributor

If inputs to demographics are provided as integers, like ASFR to Pregnancy, we get the following error due to divide:
np.divide(num_to_make, new_denom, where=new_denom>0, out=new_rate)

Exception has occurred: _UFuncOutputCastingError
Cannot cast ufunc 'divide' output from dtype('float64') to dtype('int64') with casting rule 'same_kind'
  File "/Users/dklein/GIT/starsim/starsim/demographics.py", line 350, in make_fertility_prob_fn
    np.divide(num_to_make, new_denom, where=new_denom>0, out=new_rate)
  File "/Users/dklein/GIT/starsim/starsim/distributions.py", line 512, in convert_callable
    out = val(self.module, self.sim, size_par)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/dklein/GIT/starsim/starsim/distributions.py", line 1049, in call_par
    val = self.convert_callable(key, val, size, uids)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/dklein/GIT/starsim/starsim/distributions.py", line 535, in call_pars
    val = self.call_par(key, val, size, uids)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/dklein/GIT/starsim/starsim/distributions.py", line 495, in process_pars
    self.call_pars() # Convert from function to values if needed
    ^^^^^^^^^^^^^^^^
  File "/Users/dklein/GIT/starsim/starsim/distributions.py", line 614, in rvs
    self.process_pars()
  File "/Users/dklein/GIT/starsim/starsim/distributions.py", line 1025, in filter
    bools = self.rvs(uids)
            ^^^^^^^^^^^^^^
  File "/Users/dklein/GIT/starsim/starsim/demographics.py", line 474, in make_pregnancies
    conceive_uids = self.pars.p_fertility.filter(eligible_uids)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/dklein/GIT/starsim/starsim/demographics.py", line 417, in do_step
    conceive_uids = self.make_pregnancies()
                    ^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/dklein/GIT/starsim/starsim/demographics.py", line 411, in step
    new_uids = self.do_step()
               ^^^^^^^^^^^^^^
  File "/Users/dklein/GIT/starsim/starsim/loop.py", line 192, in run
    f() # Execute the function -- this is where all of Starsim happens!!
    ^^^
  File "/Users/dklein/GIT/starsim/starsim/sim.py", line 297, in run
    self.loop.run(until)
  File "/Users/dklein/GIT/UWEpi554-ABM/demographics.py", line 42, in <module>
    sim.run()
numpy.core._exceptions._UFuncOutputCastingError: Cannot cast ufunc 'divide' output from dtype('float64') to dtype('int64') with casting rule 'same_kind'
@cliffckerr cliffckerr modified the milestones: Version 2.2, Version 2.3 Nov 13, 2024
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