BUG: stats: wrong shape from median_absolute_deviation for arrays with size 0 and an axis. #11720
Labels
defect
A clear bug or issue that prevents SciPy from being installed or used as expected
scipy.stats
Milestone
Currently,
median_absolute_deviation
returns the scalarnan
if thesize
of the input array is 0, even if anaxis
argument is given. This is not correct. The function must respect the reduction-like behavior for the shape of the arrays. For example, ifx
has shape(m, n, p)
andaxis=1
, the shape of the result must be(m, p)
, even if any ofm
,n
, orp
are 0.For example,
Here, just like
n.sum(z, axis=0)
, the result should be an array with shape (0,), but in the master branch, we incorrectly get the scalarnan
:With
axis=1
, the result should be an array with shape (3,). The values in the array should be the same as the value produced bymedian_absolute_deviation([])
, which isnan
, so the actual result should bearray([nan, nan, nan])
. But in the master branch, the behavior is again incorrect--instead of getting the array with shape (3,), we get the scalarnan
:The above code was function with the current master branch:
The text was updated successfully, but these errors were encountered: