Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.8/site-packages/bottleneck/slow/reduce.py: 93%

Shortcuts on this page

r m x   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

44 statements  

1import warnings 

2import numpy as np 

3from numpy import nanmean, nansum 

4 

5__all__ = [ 

6 "median", 

7 "nanmedian", 

8 "nansum", 

9 "nanmean", 

10 "nanvar", 

11 "nanstd", 

12 "nanmin", 

13 "nanmax", 

14 "nanargmin", 

15 "nanargmax", 

16 "ss", 

17 "anynan", 

18 "allnan", 

19] 

20 

21 

22def nanargmin(a, axis=None): 

23 "Slow nanargmin function used for unaccelerated dtypes." 

24 with warnings.catch_warnings(): 

25 warnings.simplefilter("ignore") 

26 return np.nanargmin(a, axis=axis) 

27 

28 

29def nanargmax(a, axis=None): 

30 "Slow nanargmax function used for unaccelerated dtypes." 

31 with warnings.catch_warnings(): 

32 warnings.simplefilter("ignore") 

33 return np.nanargmax(a, axis=axis) 

34 

35 

36def nanvar(a, axis=None, ddof=0): 

37 "Slow nanvar function used for unaccelerated dtypes." 

38 with warnings.catch_warnings(): 

39 warnings.simplefilter("ignore") 

40 return np.nanvar(a, axis=axis, ddof=ddof) 

41 

42 

43def nanstd(a, axis=None, ddof=0): 

44 "Slow nanstd function used for unaccelerated dtypes." 

45 with warnings.catch_warnings(): 

46 warnings.simplefilter("ignore") 

47 return np.nanstd(a, axis=axis, ddof=ddof) 

48 

49 

50def nanmin(a, axis=None): 

51 "Slow nanmin function used for unaccelerated dtypes." 

52 with warnings.catch_warnings(): 

53 warnings.simplefilter("ignore") 

54 return np.nanmin(a, axis=axis) 

55 

56 

57def nanmax(a, axis=None): 

58 "Slow nanmax function used for unaccelerated dtypes." 

59 with warnings.catch_warnings(): 

60 warnings.simplefilter("ignore") 

61 return np.nanmax(a, axis=axis) 

62 

63 

64def median(a, axis=None): 

65 "Slow median function used for unaccelerated dtypes." 

66 with warnings.catch_warnings(): 

67 warnings.simplefilter("ignore") 

68 return np.median(a, axis=axis) 

69 

70 

71def nanmedian(a, axis=None): 

72 "Slow nanmedian function used for unaccelerated dtypes." 

73 with warnings.catch_warnings(): 

74 warnings.simplefilter("ignore") 

75 return np.nanmedian(a, axis=axis) 

76 

77 

78def ss(a, axis=None): 

79 "Slow sum of squares used for unaccelerated dtypes." 

80 a = np.asarray(a) 

81 y = np.multiply(a, a).sum(axis) 

82 return y 

83 

84 

85def anynan(a, axis=None): 

86 "Slow check for Nans used for unaccelerated dtypes." 

87 return np.isnan(a).any(axis) 

88 

89 

90def allnan(a, axis=None): 

91 "Slow check for all Nans used for unaccelerated dtypes." 

92 return np.isnan(a).all(axis)