-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Closed
Labels
defectA clear bug or issue that prevents SciPy from being installed or used as expectedA clear bug or issue that prevents SciPy from being installed or used as expectedscipy.stats
Description
Describe your issue.
nan handling in winsorize for 'omit' option does not work properly. It seems to count nans as larger than any number, so if there are other large numbers they may not be winsorized. In the example below, I have 108 numbers, and winsorizing at 1% level (so max and min should be winsorized). The max (which is the last number in the array) is unchanged.
Reproducing Code Example
from scipy.stats.mstats import winsorize
import numpy as np
a = np.random.standard_normal(108)
a[0] = np.nan
a[-1] = 80
winsorize(a, limits=(0.01,0.01), nan_policy='omit')Error message
No error, but the last element of the output array is still 80, when it is clearly the largest element in the array. The code seems to be treating nan as the largest element.SciPy/NumPy/Python version information
1.7.1 1.20.3 sys.version_info(major=3, minor=9, micro=7, releaselevel='final', serial=0)
Metadata
Metadata
Assignees
Labels
defectA clear bug or issue that prevents SciPy from being installed or used as expectedA clear bug or issue that prevents SciPy from being installed or used as expectedscipy.stats