Skip to content

Commit

Permalink
Merge pull request #194 from esvhd/conf_int_bca_fix
Browse files Browse the repository at this point in the history
np.atleast_1d() fix for conf_int(method='bca') on scaler inputs.
  • Loading branch information
bashtage committed Sep 12, 2017
2 parents 994e1bc + 80c9b73 commit 3d3b390
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions arch/bootstrap/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,7 @@ def conf_int(self, func, reps=1000, method='basic', size=0.95, tail='two',
'too small to use BCa'
raise RuntimeError(message.format(jk_var=denom))
a = numer / denom
a = np.atleast_1d(a)
a = a[:, None]
else:
a = 0.0
Expand Down
13 changes: 13 additions & 0 deletions arch/tests/bootstrap/test_bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,19 @@ def func(y):
ci = ci.T
assert_allclose(ci_db, ci)

def test_conf_int_bca_scaler(self):
num_bootstrap = 100
bs = IIDBootstrap(self.y)
bs.seed(23456)

try:
ci = bs.conf_int(np.mean, reps=num_bootstrap, method='bca')
assert(ci.shape == (2, 1))
except IndexError:
pytest.fail('conf_int(method=\'bca\') scaler input regression. '
'Ensure output is at least 1D with '
'numpy.atleast_1d().')

def test_conf_int_parametric(self):
def param_func(x, params=None, state=None):
if state is not None:
Expand Down

0 comments on commit 3d3b390

Please sign in to comment.