1
The maskedarray package went through some major updates recently.
2
Originally, a MaskedArray object had two major attributes: (i) _data, a
3
(subclass of) ndarray that stored the values, and (ii) _mask, a ndarray of
4
booleans storing whether the values were masekd or not. This structure was
5
directly derived from the original implementation of MaskedArray, available in
8
However, this approach wasn't very natural. For example, in order to access the
9
data of a MaskedArray instance, one had to query the _data attribute instead of
10
the instance itself. In addition, the previous implementation of MaskedArray as
11
a subclass of ndarray presented some problems. Thus, most of the attributes of
12
a MaskedArray object were defined as class defaults, which turned out to be
13
thread-unsafe. Moreover, subclassing MaskedArray wasn't straightforward, when
14
the subclass introduced new parameters in its __new__ method.
16
The current implementation tries to alleviate these problems. The most
17
significant difference is that the _data attribute is now a view of the array
18
as a (subclass of) ndarray. The actual type is set by the _baseclass attribute,
19
defined at the creation of a new masked array as the class of the underlying
20
data. Thus, it is still possible to use a matrix object as the underlying data:
21
the new masked array will then use the matrix methods. Note that if the
22
underlying data has its own attributes, these latter are not propagated to the
23
MaskedArray instance, but are reinitialized at each access. In other terms, you
24
will lose specific values of these attributes during processing. You should
25
then consider defining a subclass of MaskedArray. Note also that because the
26
_data attribute is a view, any attempt to directly set it will likely fail. For
27
example, x._data = 5 will raise an AttributeError exception. You should then
28
use x._data[:] = 5 instead).
30
The _mask attibute is left unchanged. Because it is a basic attribute, it can
31
be overwritten far too easily. If you want to specify a new value for the mask,
32
you should use the _setmask or __setmask__ methods: these methods ensure that
33
the new mask has the same shape as the data, and that the _hardmask condition
34
is respected. Note that in some particular cases involving subclasses of
35
MaskedArray, the mask is not always propagated properly. It is recommended to
36
set the mask of the base object, instead of trying to set the mask through a
39
Following the suggestions of Reggie Dugard, the class defaults have been
40
suppressed. Unfortunately, that required to add some extra definitions in the
41
__array_finalize__ method, which tends to have a slight negative impact on
42
performances. Moreover, most methods now return a view of the masked array
43
instead of creating a new masked array from scratch.
46
The previous implementation of MaskedArray is called core_ini.py and it can be
47
found in the alternative_versions directory. This folder contains also yet
48
another implementation core_alt. This latter is left for documentation purposes,
49
and should serve as a template when we'll port the package to C. It introduces
50
yet another attribute, _masklayer. This attribute is always a ndarray of booleans
51
with the same shape as the data, that stores the values of the masked. The _mask
52
attribute is then a property, that returns _masklayer or nomask depending on
53
the value of the _smallmask flag and the values of _masklayer. This approach
54
seems to solve the anomaly in mask propagation mentioned earlier. However, some
55
performance tests show that this approach is significantly slower (from 10% to
56
50%) than the current implementation. It was therfore decided to leave it out of
59
#...............................................................................
60
2007-01-22 : core : fixed a call to numpy.float128 on 32b machines
61
2007-01-21 : core : fixed max/min_fill_values
62
: : fixed sort (as method and function)
63
2007-01-18 : core : fixed default filling values for unsigned int_.
64
2007-01-16 : extras : new function : `mediff1d`
65
2007-01-15 : mrecords: new method: `addfield`
66
: core : Force the mask of a masked array `x` to be copied w/...
67
...masked_array(x,copy=True,mask=nomask,keep_mask=true)
68
2007-01-14 : mrecords: Slices are now properly supported
69
: mrecords: `filled` is now properly supported
70
2007-01-12 : mrecords: Complete reorganization...
71
2007-01-10 : mrecords: Defines a class of records that support masked arrays
73
: core : Force a reset of the class defaults after initialization
74
: core : Modified __array_finallize__ to allow objects w/ _data...
75
... _mask fields to be recognized as MA
76
2007-01-04 : core : Fixed a but in masked_all_like
77
2007-01-02 : extras : Force apply_along_axis to output the proper fill_value
78
: core : Can use dtypes for the definition of default_fill_value
79
2006-12-30 : core : Cleaned up setitem/setslice w/ hard_mask=True
80
: core : Fixed masked_unary/binary_operations...
81
...to work with subclasses of MaskedArray
82
2006-12-22 : core : Optimized(?) default_/maximum_/minimum_fill_value
83
: core : Force __new__ to not return a MaskedArray, in order to ...
84
: ... optimize __array_finalize__
85
: core : Add the hard_mask flag to __new__ (*[False]*)
86
2006-12-19 : core : Fixed a problem on _set_mask which prevented to set a mask to nomask
87
: extras : Renamed compress2d to compress_rowcols
89
2006-12-18 : extras : Added compress2d and mask_rowcols
90
: extras : moved 'average' to 'extras'
91
2006-12-13 : core : Fixed make_mask (forced filling to True)
93
: core : Fixed error message in __new__ when wrong sizes
94
: core : Fixed the reshape function.
95
: extras : masked_all: set default dtype to float_
96
: extras : _fromnxfunctions: make sure that list are recognized
97
: extras : added notmasked_edges, notmasked_contiguous
98
2006-12-09 : - Code reorganization: define 2 modules, core and extras
99
2006-11-25 : core : Disable copy by default
100
core : Added keep_mask flag (to save mask when creating a ma from a ma)
101
core : Fixed functions: empty_like
102
core : Fixed methods: .any and .all
103
core : New functions: masked_all, masked_all_like
104
core : New methods: .squeeze
105
2006-11-20 : core : fixed make_mask
106
core : fixed nonzero method
107
2006-11-16 : core : fixed .T
108
2006-11-12 : core : add max, min as function (not only method...)
109
core : repr returns a name like masked_xxx, where xxx is the subclass
110
2006-10-31 : core : make sure that make_mask returns a pure ndarray.
111
2006-10-30 : core : When converted to a float, a masked singleton is ...
112
...transformed to nan instead of raising an exception.
113
21: Use __get__ method in _arraymethods, _arithmethods, _compamethods
114
18: Updated put to match the definition of numpy 1.0, deleted putmask, changed resize
115
2: prevent an extra kword being sent to make_mask_none
117
#............................................................
b'\\ No newline at end of file'