Skip to content

Commit

Permalink
bootstrap_analysis: fix error when analyzing scalar variables (#402)
Browse files Browse the repository at this point in the history
  • Loading branch information
luisfabib committed Dec 9, 2022
1 parent 15821e2 commit 7fb71ca
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion deerlab/bootstrap_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def sample():

# Assert that all outputs are strictly numerical
for var in varargout:
if not all(isnumeric(x) for x in var):
if not all(isnumeric(x) for x in np.atleast_1d(var)):
raise ValueError('Non-numeric output arguments by the analyzed function are not accepted.')

# Check that the full bootstrap analysis will not exceed the memory limits
Expand Down
8 changes: 4 additions & 4 deletions test/test_bootstrap_analysis.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

import numpy as np
from deerlab import dipolarkernel, whitegaussnoise, bootstrap_analysis, snlls
from deerlab import whitegaussnoise, bootstrap_analysis, snlls
from deerlab.dd_models import dd_gauss
from deerlab.utils import assert_docstring

Expand All @@ -25,7 +25,7 @@ def fitfcn_global(ys):

def fitfcn_multiout(yexp):
fit = snlls(yexp,model,[1,3],uq=False)
return fit.nonlin*fit.lin, fit.model
return fit.nonlin*fit.lin, fit.model, fit.nonlin[0]

def fitfcn_complex(yexp):
fit = snlls(yexp,model,[1,3],uq=False)
Expand Down Expand Up @@ -58,10 +58,10 @@ def test_multiple_ouputs():
# ======================================================================
"Check that both bootstrap handles the correct number outputs"

parfit,yfit = fitfcn_multiout(yexp)
parfit,yfit,_ = fitfcn_multiout(yexp)
paruq = bootstrap_analysis(fitfcn_multiout,yexp,model(parfit),10)

assert len(paruq)==2 and all(abs(paruq[0].mean - parfit)) and all(abs(paruq[1].mean - yfit))
assert len(paruq)==3 and all(abs(paruq[0].mean - parfit)) and all(abs(paruq[1].mean - yfit))
# ======================================================================

def test_multiple_datasets():
Expand Down

0 comments on commit 7fb71ca

Please sign in to comment.