1"""

2=============

3 Masked Arrays

4=============

5

6 Arrays sometimes contain invalid or missing data. When doing operations

7 on such arrays, we wish to suppress invalid values, which is the purpose masked

8 arrays fulfill (an example of typical use is given below).

9

10 For example, examine the following array:

11

12>>> x = np.array([2, 1, 3, np.nan, 5, 2, 3, np.nan])

13

14 When we try to calculate the mean of the data, the result is undetermined:

15

16>>> np.mean(x)

17 nan

18

19 The mean is calculated using roughly ``np.sum(x)/len(x)``, but since

20 any number added to ``NaN`` [1]_ produces ``NaN``, this doesn't work. Enter

21 masked arrays:

22

23>>> m = np.ma.masked_array(x, np.isnan(x))

24>>> m

25 masked_array(data = [2.0 1.0 3.0 -- 5.0 2.0 3.0 --],

26 mask = [False False False True False False False True],

27 fill_value=1e+20)

28

29 Here, we construct a masked array that suppress all ``NaN`` values. We

30 may now proceed to calculate the mean of the other values:

31

32>>> np.mean(m)

33 2.6666666666666665

34

35.. [1] Not-a-Number, a floating point value that is the result of an

36 invalid operation.

37

38.. moduleauthor:: Pierre Gerard-Marchant

39.. moduleauthor:: Jarrod Millman

40

41"""

42 from . import core

43 from .core import *

44

45 from . import extras

46 from .extras import *

47

48__all__ = ['core', 'extras']

49__all__ += core.__all__

50__all__ += extras.__all__

51

52 from numpy._pytesttester import PytestTester

53 test = PytestTester(__name__)

54 del PytestTester