Flaky test `test/sample/test_sample.py::test_samples_cis`
See original GitHub issueSee https://github.com/ICB-DCM/pyPESTO/runs/7522438577?check_suite_focus=true
_______________________________ test_samples_cis _______________________________
def test_samples_cis():
"""
Test whether :py:func:`pypesto.sample.calculate_ci_mcmc_sample` produces
percentile-based credibility intervals correctly.
"""
# load problem
problem = gaussian_problem()
# set a sampler
sampler = sample.MetropolisSampler(
options={
'show_progress': False,
},
)
# optimization
result = optimize.minimize(
problem=problem,
n_starts=3,
filename=None,
progress_bar=False,
)
# sample
result = sample.sample(
problem=problem,
sampler=sampler,
n_samples=2000,
result=result,
filename=None,
)
# run geweke test
sample.geweke_test(result)
# get converged chain
converged_chain = np.asarray(
result.sample_result.trace_x[0, result.sample_result.burn_in :, :]
)
# set confidence levels
alpha_values = [0.99, 0.95, 0.68]
# loop over confidence levels
for alpha in alpha_values:
# calculate parameter samples confidence intervals
> lb, ub = sample.calculate_ci_mcmc_sample(result, ci_level=alpha)
test/sample/test_sample.py:718:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
pypesto/sample/util.py:46: in calculate_ci_mcmc_sample
lb, ub = calculate_ci(chain, ci_level=ci_level, axis=0)
pypesto/sample/util.py:96: in calculate_ci
lb, ub = np.percentile(values, percentiles, **kwargs)
<__array_function__ internals>:180: in percentile
???
.tox/base/lib/python3.8/site-packages/numpy/lib/function_base.py:4134: in percentile
return _quantile_unchecked(
.tox/base/lib/python3.8/site-packages/numpy/lib/function_base.py:4383: in _quantile_unchecked
r, k = _ureduce(a,
.tox/base/lib/python3.8/site-packages/numpy/lib/function_base.py:3702: in _ureduce
r = func(a, **kwargs)
.tox/base/lib/python3.8/site-packages/numpy/lib/function_base.py:4552: in _quantile_ureduce_func
result = _quantile(arr,
.tox/base/lib/python3.8/site-packages/numpy/lib/function_base.py:4658: in _quantile
take(arr, indices=-1, axis=DATA_AXIS)
<__array_function__ internals>:180: in take
???
.tox/base/lib/python3.8/site-packages/numpy/core/fromnumeric.py:190: in take
return _wrapfunc(a, 'take', indices, axis=axis, out=out, mode=mode)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
obj = array([], shape=(0, 1), dtype=float64), method = 'take', args = (-1,)
kwds = {'axis': 0, 'mode': 'raise', 'out': None}
bound = <built-in method take of numpy.ndarray object at 0x7fdfbc362c90>
def _wrapfunc(obj, method, *args, **kwds):
bound = getattr(obj, method, None)
if bound is None:
return _wrapit(obj, method, *args, **kwds)
try:
> return bound(*args, **kwds)
E IndexError: cannot do a non-empty take from an empty axes.
.tox/base/lib/python3.8/site-packages/numpy/core/fromnumeric.py:57: IndexError
Issue Analytics
- State:
- Created a year ago
- Comments:6 (6 by maintainers)
Top Results From Across the Web
Flaky test — The Practical Testing Book
These non-deterministic tests are known as Flaky Tests and they are more ... You can execute the example brought by this chapter by...
Read more >Flaky tests - GitLab Docs
Flaky tests. What's a flaky test? It's a test that sometimes fails, but if you retry it enough times, it passes, eventually.
Read more >Flaky tests — pytest documentation
A “flaky” test is one that exhibits intermittent or sporadic failure, that seems to have non-deterministic behaviour. Sometimes it passes, sometimes it ...
Read more >How to Fix Flaky Tests - Semaphore CI
Randomly failing tests are the hardest to debug. Here's a framework you can use to fix them and keep your test suite healthy....
Read more >getsentry/pytest-sentry: Track flaky tests in Sentry - GitHub
Tracking flaky tests as errors The known workaround is to retry those tests automatically, for example using pytest-rerunfailures. One concern against plugins ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@elbaraim it appears that this is a problem of auto-calculated burn-in, in case the entire array is found to be burn-in. I guess in this case an appropriate error should be thrown, and the test adjusted.
Still happening… https://github.com/ICB-DCM/pyPESTO/actions/runs/3280972663/jobs/5402409945