Describe the issue:
Asking for the 1 quantile with weibull gives a confusing error - see below.
Reproduce the code example:
import numpy as np
np.quantile(np.arange(10), 1, method='weibull')
Error message:
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
Cell In [57], line 1
----> 1 np.quantile(np.arange(10), 1, method='weibull')
File <__array_function__ internals>:180, in quantile(*args, **kwargs)
File ~/Library/Python/3.10/lib/python/site-packages/numpy/lib/function_base.py:4412, in quantile(a, q, axis, out, overwrite_input, method, keepdims, interpolation)
4410 if not _quantile_is_valid(q):
4411 raise ValueError("Quantiles must be in the range [0, 1]")
-> 4412 return _quantile_unchecked(
4413 a, q, axis, out, overwrite_input, method, keepdims)
File ~/Library/Python/3.10/lib/python/site-packages/numpy/lib/function_base.py:4424, in _quantile_unchecked(a, q, axis, out, overwrite_input, method, keepdims)
4416 def _quantile_unchecked(a,
4417 q,
4418 axis=None,
(...)
4421 method="linear",
4422 keepdims=False):
4423 """Assumes that q is in [0, 1], and is an ndarray"""
-> 4424 r, k = _ureduce(a,
4425 func=_quantile_ureduce_func,
4426 q=q,
4427 axis=axis,
4428 out=out,
4429 overwrite_input=overwrite_input,
4430 method=method)
4431 if keepdims:
4432 return r.reshape(q.shape + k)
File ~/Library/Python/3.10/lib/python/site-packages/numpy/lib/function_base.py:3725, in _ureduce(a, func, **kwargs)
3722 else:
3723 keepdim = (1,) * a.ndim
-> 3725 r = func(a, **kwargs)
3726 return r, keepdim
File ~/Library/Python/3.10/lib/python/site-packages/numpy/lib/function_base.py:4593, in _quantile_ureduce_func(a, q, axis, out, overwrite_input, method)
4591 else:
4592 arr = a.copy()
-> 4593 result = _quantile(arr,
4594 quantiles=q,
4595 axis=axis,
4596 method=method,
4597 out=out)
4598 return result
File ~/Library/Python/3.10/lib/python/site-packages/numpy/lib/function_base.py:4683, in _quantile(arr, quantiles, axis, method, out)
4680 slices_having_nans = np.isnan(arr[-1])
4681 else:
4682 # cannot contain nan
-> 4683 arr.partition(virtual_indexes.ravel(), axis=0)
4684 slices_having_nans = np.array(False, dtype=bool)
4685 result = take(arr, virtual_indexes, axis=0, out=out)
ValueError: kth(=10) out of bounds (10)
[1] import sys, numpy; print(numpy.version); print(sys.version)
1.26.0b1
3.10.11 (main, Apr 7 2023, 07:24:53) [Clang 14.0.0 (clang-1400.0.29.202)]
In [2]: print(numpy.show_runtime())
WARNING: threadpoolctl not found in system! Install it by pip install threadpoolctl. Once installed, try np.show_runtime again for more detailed build information
[{'numpy_version': '1.26.0b1',
'python': '3.10.11 (main, Apr 7 2023, 07:24:53) [Clang 14.0.0 '
'(clang-1400.0.29.202)]',
'uname': uname_result(system='Darwin', node='nipraxis.dynevor.org', release='22.6.0', version='Darwin Kernel Version 22.6.0: Wed Jul 5 22:17:35 PDT 2023; root:xnu-8796.141.3~6/RELEASE_ARM64_T8112', machine='arm64')},
{'simd_extensions': {'baseline': ['NEON', 'NEON_FP16', 'NEON_VFPV4', 'ASIMD'],
'found': ['ASIMDHP'],
'not_found': ['ASIMDFHM']}}]
### Context for the issue:
Writing a tutorial on quantiles, and failing to understand them!
Describe the issue:
Asking for the 1 quantile with
weibullgives a confusing error - see below.Reproduce the code example:
Error message:
[1] import sys, numpy; print(numpy.version); print(sys.version)
1.26.0b1
3.10.11 (main, Apr 7 2023, 07:24:53) [Clang 14.0.0 (clang-1400.0.29.202)]
In [2]: print(numpy.show_runtime())
WARNING:
threadpoolctlnot found in system! Install it bypip install threadpoolctl. Once installed, trynp.show_runtimeagain for more detailed build information[{'numpy_version': '1.26.0b1',
'python': '3.10.11 (main, Apr 7 2023, 07:24:53) [Clang 14.0.0 '
'(clang-1400.0.29.202)]',
'uname': uname_result(system='Darwin', node='nipraxis.dynevor.org', release='22.6.0', version='Darwin Kernel Version 22.6.0: Wed Jul 5 22:17:35 PDT 2023; root:xnu-8796.141.3~6/RELEASE_ARM64_T8112', machine='arm64')},
{'simd_extensions': {'baseline': ['NEON', 'NEON_FP16', 'NEON_VFPV4', 'ASIMD'],
'found': ['ASIMDHP'],
'not_found': ['ASIMDFHM']}}]