Skip to content
Browse files

WIP use new numpy nan functions...

test fail due to bugs in numpy
  • Loading branch information...
1 parent 9c5038e commit 838a8d406ff659b59e3f4199b3f348851a9d0d98 @kwgoodman committed Oct 7, 2013
Showing with 3 additions and 31 deletions.
  1. +3 −31 bottleneck/slow/func.py
View
34 bottleneck/slow/func.py
@@ -50,45 +50,17 @@ def nanmedian(arr, axis=None):
def nanmean(arr, axis=None):
"Slow nanmean function used for unaccelerated ndim/dtype combinations."
- arr = np.asarray(arr)
- y = scipy_nanmean(arr, axis=axis)
- if y.dtype != arr.dtype:
- if issubclass(arr.dtype.type, np.inexact):
- y = y.astype(arr.dtype)
- return y
+ return np.nanmean(arr, axis=axis)
def nanvar(arr, axis=None, ddof=0):
"Slow nanvar function used for unaccelerated ndim/dtype combinations."
- arr = np.asarray(arr)
- y = nanstd(arr, axis=axis, ddof=ddof)
- return y * y
+ return np.nanvar(arr, axis=axis, ddof=ddof)
def nanstd(arr, axis=None, ddof=0):
"Slow nanstd function used for unaccelerated ndim/dtype combinations."
- arr = np.asarray(arr)
- if ddof == 0:
- bias = True
- elif ddof == 1:
- bias = False
- else:
- raise ValueError("With NaNs ddof must be 0 or 1.")
- if axis is not None:
- # Older versions of scipy can't handle negative axis?
- if axis < 0:
- axis += arr.ndim
- if (axis < 0) or (axis >= arr.ndim):
- raise ValueError("axis(=%d) out of bounds" % axis)
- else:
- # Older versions of scipy choke on axis=None
- arr = arr.ravel()
- axis = 0
- y = scipy_nanstd(arr, axis=axis, bias=bias)
- if y.dtype != arr.dtype:
- if issubclass(arr.dtype.type, np.inexact):
- y = y.astype(arr.dtype)
- return y
+ return np.nanstd(arr, axis=axis, ddof=ddof)
def nanmin(arr, axis=None):

0 comments on commit 838a8d4

Please sign in to comment.
Something went wrong with that request. Please try again.