comparison DEPENDENCIES/mingw32/Python27/Lib/site-packages/numpy/ma/__init__.py @ 87:2a2c65a20a8b

Add Python libs and headers
author Chris Cannam
date Wed, 25 Feb 2015 14:05:22 +0000
parents
children
comparison
equal deleted inserted replaced
86:413a9d26189e 87:2a2c65a20a8b
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 """
39 from __future__ import division, absolute_import, print_function
40
41 __author__ = "Pierre GF Gerard-Marchant ($Author: jarrod.millman $)"
42 __version__ = '1.0'
43 __revision__ = "$Revision: 3473 $"
44 __date__ = '$Date: 2007-10-29 17:18:13 +0200 (Mon, 29 Oct 2007) $'
45
46 from . import core
47 from .core import *
48
49 from . import extras
50 from .extras import *
51
52 __all__ = ['core', 'extras']
53 __all__ += core.__all__
54 __all__ += extras.__all__
55
56 from numpy.testing import Tester
57 test = Tester().test
58 bench = Tester().bench