PRF: Added nanmean, nanstd, nansum that will default to bottleneck if available

This commit is contained in:
Dale Jung
2015-02-25 09:15:14 -05:00
committed by Eddie Hebert
parent fd21b4697e
commit 29e5f7ee86
+15
View File
@@ -14,7 +14,22 @@
# limitations under the License.
import math
import numpy as np
def tolerant_equals(a, b, atol=10e-7, rtol=10e-7):
return math.fabs(a - b) <= (atol + rtol * math.fabs(b))
nanmean = np.nanmean
nanstd = np.nanstd
nansum = np.nansum
try:
import bottleneck as bn
nanmean = bn.nanmean
nanstd = bn.nanstd
nansum = bn.nansum
except ImportError:
pass