danielapai / bioverse

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

ValueError raised when empty dataset passed into Hypothesis.fit() #47

Closed astral-carrier closed 5 months ago

astral-carrier commented 5 months ago

This error was a result of running a modified version of Example1.ipynb with d_max=3, eta_earth=0.01 added to the parameters to analysis.test_hypothesis_grid() in the code cell directly under "Computing statistical power". It consistently occurred every time I ran the notebook.

This may be related to #46. I cannot attach the test notebook to this issue, but I will provide it in Slack.

Error

Note: During testing, I made changes to Hypothesis.fit() that added some debugging output to the error message.

 30%|██▉       | 59/200 [00:35<01:24,  1.67it/s]

Interrupted, terminating remaining processes

multiprocessing.pool.RemoteTraceback: 
"""
Traceback (most recent call last):
  File "/Users/bioversedev/Documents/GitHub/bioverse/bioverse/hypothesis.py", line 295, in fit
    theta_opt, theta_opt_null = chains[np.argmax(loglikes)], np.mean(Y, axis=0)
                                       ^^^^^^^^^^^^^^^^^^^
  File "/Users/bioversedev/miniconda3/envs/biodev/lib/python3.12/site-packages/numpy/core/fromnumeric.py", line 1229, in argmax
    return _wrapfunc(a, 'argmax', axis=axis, out=out, **kwds)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/bioversedev/miniconda3/envs/biodev/lib/python3.12/site-packages/numpy/core/fromnumeric.py", line 59, in _wrapfunc
    return bound(*args, **kwds)
           ^^^^^^^^^^^^^^^^^^^^
ValueError: attempt to get argmax of an empty sequence

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/Users/bioversedev/miniconda3/envs/biodev/lib/python3.12/multiprocessing/pool.py", line 125, in worker
    result = (True, func(*args, **kwds))
                    ^^^^^^^^^^^^^^^^^^^
  File "/Users/bioversedev/Documents/GitHub/bioverse/bioverse/analysis.py", line 109, in test_hypothesis_grid_iter
    results = h.fit(data, return_chains=return_chains, method=method, nlive=nlive, mw_alternative=mw_alternative)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/bioversedev/Documents/GitHub/bioverse/bioverse/hypothesis.py", line 297, in fit
    raise ValueError(f"""chains: {chains}
ValueError: chains: []
loglikes: []
data: 
"""

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/Users/bioversedev/Documents/GitHub/bioverse/bioverse/analysis.py", line 51, in test_hypothesis_grid
    res = procs[idx].get()
          ^^^^^^^^^^^^^^^^
  File "/Users/bioversedev/miniconda3/envs/biodev/lib/python3.12/multiprocessing/pool.py", line 774, in get
    raise self._value
ValueError: chains: []
loglikes: []
data: 
matiscke commented 5 months ago

Probably indeed related to #46 .