question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Confusing warning for median of empty array.

See original GitHub issue
In [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:open
  • Created 8 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
rgommerscommented, Aug 12, 2015

This one is specific to mean/median so can simply be removed:

warnings.warn("Mean of empty slice.", RuntimeWarning)

This one is general but god-awful:

RuntimeWarning: invalid value encountered in double_scalars

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 change double_scalars to some sensible phrase like arithmetic operation on arrays.

0reactions
argriffingcommented, Aug 12, 2015
Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found