danielapai / bioverse

A simulation framework to assess the statistical power of future biosignature surveys
MIT License
7 stars 5 forks source link

truncnorm 'scale' parameter must be positive #48

Open kevinkhu opened 5 months ago

kevinkhu commented 5 months ago

While running a test_hypothesis_grid I run into issues with the truncnorm function in util.py. I got this error before, so attempted to put a np.abs(b) in for scale, but it did not fix the issue. It looks like the program continued running, however, despite this error. (It did break later for another issue.)

  5%|████████▏                                                                                                                                                           | 25/500 [3:23:41<61:15:17, 464.25s/it]Traceback (most recent call last):
  File "/home/kevin/Python/bioverse/bioverse/generator.py", line 158, in generate
    d = self.steps[i].run(d,**kwargs)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/kevin/Python/bioverse/bioverse/generator.py", line 236, in run
    return func(d,**kwargs2)
           ^^^^^^^^^^^^^^^^^
  File "/home/kevin/Python/bioverse/bioverse/functions.py", line 912, in assign_mass
    M[mask1] = util.normal(2.7*R[mask1]**1.3,1.9,0.01,10000,mask1.sum())
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/kevin/Python/bioverse/bioverse/util.py", line 309, in normal
    return truncnorm_hack.truncnorm.rvs(a=aa,b=bb,loc=a,scale=np.abs(b),size=size)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/kevin/anaconda3/lib/python3.11/site-packages/scipy/stats/_distn_infrastructure.py", line 1055, in rvs
    raise ValueError(message)
ValueError: Domain error in arguments. The `scale` parameter must be positive for all distributions, and many distributions have restrictions on shape parameters. Please see the `scipy.stats.truncnorm` documentation for details.
  7%|██████████▊                                                                                                                                                         | 33/500 [5:04:20<91:37:49, 706.36s/it]Traceback (most recent call last):
  File "/home/kevin/Python/bioverse/bioverse/generator.py", line 158, in generate
    d = self.steps[i].run(d,**kwargs)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/kevin/Python/bioverse/bioverse/generator.py", line 236, in run
    return func(d,**kwargs2)
           ^^^^^^^^^^^^^^^^^
  File "/home/kevin/Python/bioverse/bioverse/functions.py", line 912, in assign_mass
    M[mask1] = util.normal(2.7*R[mask1]**1.3,1.9,0.01,10000,mask1.sum())
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/kevin/Python/bioverse/bioverse/util.py", line 309, in normal
    return truncnorm_hack.truncnorm.rvs(a=aa,b=bb,loc=a,scale=np.abs(b),size=size)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/kevin/anaconda3/lib/python3.11/site-packages/scipy/stats/_distn_infrastructure.py", line 1055, in rvs
    raise ValueError(message)
ValueError: Domain error in arguments. The `scale` parameter must be positive for all distributions, and many distributions have restrictions on shape parameters. Please see the `scipy.stats.truncnorm` documentation for details.
 10%|████████████████                                                                                                                                                    | 49/500 [6:29:29<59:44:55, 476.93s/it]
matiscke commented 5 months ago

@kevinkhu did this occur again? Do you think it may be related to the empty sample issue?