scipy.stats.spearmanr unexpected NaN handling #6530
Labels
defect
A clear bug or issue that prevents SciPy from being installed or used as expected
scipy.stats
Milestone
Neither
nan_policy='omit'
nornan_policy='propagate'
(the default) does what I would expect.The docs say that
propagate
should return nan, but I haven't seen that happen. It simply seems to rank nan above any other value. For example:0.4 is the correct result if
x[1,1]
is instead 15. We can also see this when passing two one-dimensional arrays:Again, this is the correct result if
x[1,1]
is 15.Meanwhile,
omit
seems to correctly handle the case of two one-dimensional arrays, in that it returns the same result as if you filter out indexes which are nan in either array.But
omit
seems to cause thea
andb
arguments to be raveled, and calculates a single correlation coefficient. Ifb
is missing, or doesn't have the same number of entries asa
, we get an error.This shouldn't be an error.
There are six variables here, but only a single result.
It looks as though these arrays are being raveled.
The
a
andb
arguments here have different dimensions, so this should throw an error; but again, it simply seems to be ravelling them.(When there are no nan values,
omit
seems to have no effect.)The text was updated successfully, but these errors were encountered: