Confusing warning for median of empty array.
See original GitHub issueIn [1]: np.median([])
/usr/lib/python3.4/site-packages/numpy/core/_methods.py:59: RuntimeWarning: Mean of empty slice.
warnings.warn("Mean of empty slice.", RuntimeWarning)
Out[1]: nan
Oops. [numpy 1.9.2]
Issue Analytics
- State:
- Created 8 years ago
- Comments:6 (6 by maintainers)
Top Results From Across the Web
numpy.median of empty array now yields error in version 1.10.0
In numpy 1.9.3, np.median(np.array([])) produces a NaN (and a warning about taking a mean of empty slice). The same code ...
Read more >What is the median of an empty set? - Math Stack Exchange
The median of a set A is the value ˜μ such that the sets {x∈A:x<˜μ} and {x∈A:x>˜μ} have the same number of elements,...
Read more >Working with missing data — pandas 1.5.2 documentation
To make detecting missing values easier (and across different array dtypes), ... The sum of an empty or all-NA Series or column of...
Read more >Look Ma, No For-Loops: Array Programming With NumPy
When looping over an array or any data structure in Python, there's a lot of overhead involved. Vectorized operations in NumPy delegate the...
Read more >aggregateWindow() function | Flux 0.x Documentation
If timeColumn is in the group key, resulting output is confusing and ... Note: When using createEmpty: true , aggregate functions return empty...
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 FreeTop 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
Top GitHub Comments
This one is specific to mean/median so can simply be removed:
This one is general but god-awful:
double_scalars
is meaningless. I think the invalid value warning should be kept, but the message should be modified to include the actual function it came from if possible. And otherwise changedouble_scalars
to some sensible phrase likearithmetic operation on arrays
.Related PR https://github.com/numpy/numpy/pull/5753.