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

bootstrap_analysis: Fix error when analyzing scalar variables #402

Merged
merged 3 commits into from
Nov 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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