Skip to content

Commit 3d3b390

Browse files
authored
Merge pull request #194 from esvhd/conf_int_bca_fix
np.atleast_1d() fix for conf_int(method='bca') on scaler inputs.
2 parents 994e1bc + 80c9b73 commit 3d3b390

2 files changed

Lines changed: 14 additions & 0 deletions

File tree

arch/bootstrap/base.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,7 @@ def conf_int(self, func, reps=1000, method='basic', size=0.95, tail='two',
461461
'too small to use BCa'
462462
raise RuntimeError(message.format(jk_var=denom))
463463
a = numer / denom
464+
a = np.atleast_1d(a)
464465
a = a[:, None]
465466
else:
466467
a = 0.0

arch/tests/bootstrap/test_bootstrap.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -457,6 +457,19 @@ def func(y):
457457
ci = ci.T
458458
assert_allclose(ci_db, ci)
459459

460+
def test_conf_int_bca_scaler(self):
461+
num_bootstrap = 100
462+
bs = IIDBootstrap(self.y)
463+
bs.seed(23456)
464+
465+
try:
466+
ci = bs.conf_int(np.mean, reps=num_bootstrap, method='bca')
467+
assert(ci.shape == (2, 1))
468+
except IndexError:
469+
pytest.fail('conf_int(method=\'bca\') scaler input regression. '
470+
'Ensure output is at least 1D with '
471+
'numpy.atleast_1d().')
472+
460473
def test_conf_int_parametric(self):
461474
def param_func(x, params=None, state=None):
462475
if state is not None:

0 commit comments

Comments
 (0)