Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

REF remove local copies of scipy's nanstd, nanmean

  • Loading branch information...
commit 957aaba4707f837285b45128e36e7d170edb175e 1 parent d24e96f
@kwgoodman authored
Showing with 0 additions and 103 deletions.
  1. +0 −103 bottleneck/slow/func.py
View
103 bottleneck/slow/func.py
@@ -217,109 +217,6 @@ def allnan(arr, axis=None):
# rankdata taken from scipy HEAD on Mar 16, 2011.
-def scipy_nanmean(x, axis=0):
- """
- Compute the mean over the given axis ignoring nans.
-
- Parameters
- ----------
- x : ndarray
- Input array.
- axis : int, optional
- Axis along which the mean is computed. Default is 0, i.e. the
- first axis.
-
- Returns
- -------
- m : float
- The mean of `x`, ignoring nans.
-
- See Also
- --------
- nanstd, nanmedian
-
- Examples
- --------
- >>> from scipy import stats
- >>> a = np.linspace(0, 4, 3)
- >>> a
- array([ 0., 2., 4.])
- >>> a[-1] = np.nan
- >>> stats.nanmean(a)
- 1.0
-
- """
- x, axis = _chk_asarray(x, axis)
- x = x.copy()
- Norig = x.shape[axis]
- factor = 1.0-np.sum(np.isnan(x), axis)*1.0/Norig
-
- x[np.isnan(x)] = 0
- return np.mean(x, axis)/factor
-
-
-def scipy_nanstd(x, axis=0, bias=False):
- """
- Compute the standard deviation over the given axis, ignoring nans.
-
- Parameters
- ----------
- x : array_like
- Input array.
- axis : int or None, optional
- Axis along which the standard deviation is computed. Default is 0.
- If None, compute over the whole array `x`.
- bias : bool, optional
- If True, the biased (normalized by N) definition is used. If False
- (default), the unbiased definition is used.
-
- Returns
- -------
- s : float
- The standard deviation.
-
- See Also
- --------
- nanmean, nanmedian
-
- Examples
- --------
- >>> from scipy import stats
- >>> a = np.arange(10, dtype=float)
- >>> a[1:3] = np.nan
- >>> np.std(a)
- nan
- >>> stats.nanstd(a)
- 2.9154759474226504
- >>> stats.nanstd(a.reshape(2, 5), axis=1)
- array([ 2.0817, 1.5811])
- >>> stats.nanstd(a.reshape(2, 5), axis=None)
- 2.9154759474226504
-
- """
- x, axis = _chk_asarray(x, axis)
- x = x.copy()
- Norig = x.shape[axis]
-
- Nnan = np.sum(np.isnan(x), axis)*1.0
- n = Norig - Nnan
-
- x[np.isnan(x)] = 0.
- m1 = np.sum(x, axis)/n
-
- if axis:
- d = (x - np.expand_dims(m1, axis))**2.0
- else:
- d = (x - m1)**2.0
-
- m2 = np.sum(d, axis)-(m1*m1)*Nnan
- if bias:
- m2c = m2 / n
- else:
- m2c = m2 / (n - 1.)
- return np.sqrt(m2c)
-
-
def _nanmedian(arr1d): # This only works on 1d arrays
"""Private function for rank a arrays. Compute the median ignoring Nan.
Please sign in to comment.
Something went wrong with that request. Please try again.