summaryrefslogtreecommitdiff
path: root/numpy/ma
diff options
context:
space:
mode:
Diffstat (limited to 'numpy/ma')
-rw-r--r--numpy/ma/core.py48
-rw-r--r--numpy/ma/extras.py26
-rw-r--r--numpy/ma/morestats.py16
-rw-r--r--numpy/ma/mrecords.py22
-rw-r--r--numpy/ma/mstats.py38
-rw-r--r--numpy/ma/tests/test_core.py2
-rw-r--r--numpy/ma/tests/test_extras.py8
-rw-r--r--numpy/ma/tests/test_mrecords.py40
-rw-r--r--numpy/ma/testutils.py2
9 files changed, 100 insertions, 102 deletions
diff --git a/numpy/ma/core.py b/numpy/ma/core.py
index 959fa619e..83c74a12e 100644
--- a/numpy/ma/core.py
+++ b/numpy/ma/core.py
@@ -26,13 +26,13 @@ __all__ = ['MAError', 'MaskType', 'MaskedArray',
'arctanh', 'argmax', 'argmin', 'argsort', 'around',
'array', 'asarray','asanyarray',
'bitwise_and', 'bitwise_or', 'bitwise_xor',
- 'ceil', 'choose', 'common_fill_value', 'compress', 'compressed',
+ 'ceil', 'choose', 'common_fill_value', 'compress', 'compressed',
'concatenate', 'conjugate', 'cos', 'cosh', 'count',
'default_fill_value', 'diagonal', 'divide', 'dump', 'dumps',
'empty', 'empty_like', 'equal', 'exp',
'fabs', 'fmod', 'filled', 'floor', 'floor_divide','fix_invalid',
'frombuffer', 'fromfunction',
- 'getdata','getmask', 'getmaskarray', 'greater', 'greater_equal',
+ 'getdata','getmask', 'getmaskarray', 'greater', 'greater_equal',
'hypot',
'identity', 'ids', 'indices', 'inner', 'innerproduct',
'isMA', 'isMaskedArray', 'is_mask', 'is_masked', 'isarray',
@@ -41,16 +41,16 @@ __all__ = ['MAError', 'MaskType', 'MaskedArray',
'make_mask', 'make_mask_none', 'mask_or', 'masked',
'masked_array', 'masked_equal', 'masked_greater',
'masked_greater_equal', 'masked_inside', 'masked_invalid',
- 'masked_less','masked_less_equal', 'masked_not_equal',
- 'masked_object','masked_outside', 'masked_print_option',
- 'masked_singleton','masked_values', 'masked_where', 'max', 'maximum',
+ 'masked_less','masked_less_equal', 'masked_not_equal',
+ 'masked_object','masked_outside', 'masked_print_option',
+ 'masked_singleton','masked_values', 'masked_where', 'max', 'maximum',
'mean', 'min', 'minimum', 'multiply',
'negative', 'nomask', 'nonzero', 'not_equal',
'ones', 'outer', 'outerproduct',
'power', 'product', 'ptp', 'put', 'putmask',
'rank', 'ravel', 'remainder', 'repeat', 'reshape', 'resize',
'right_shift', 'round_',
- 'set_fill_value', 'shape', 'sin', 'sinh', 'size', 'sometrue', 'sort',
+ 'set_fill_value', 'shape', 'sin', 'sinh', 'size', 'sometrue', 'sort',
'sqrt', 'std', 'subtract', 'sum', 'swapaxes',
'take', 'tan', 'tanh', 'transpose', 'true_divide',
'var', 'where',
@@ -192,7 +192,7 @@ def _check_fill_value(fill_value, dtype):
else:
fill_value = default_fill_value(dtype)
else:
- fill_value = narray(fill_value).tolist()
+ fill_value = narray(fill_value).tolist()
fval = numpy.resize(fill_value, len(descr))
if len(descr) > 1:
fill_value = [numpy.asarray(f).astype(d[1]).item()
@@ -259,7 +259,7 @@ def filled(a, value = None):
"""
if hasattr(a, 'filled'):
return a.filled(value)
- elif isinstance(a, ndarray):
+ elif isinstance(a, ndarray):
# Should we check for contiguity ? and a.flags['CONTIGUOUS']:
return a
elif isinstance(a, dict):
@@ -1579,21 +1579,21 @@ class MaskedArray(numeric.ndarray):
if self._mask is not nomask:
data = data[numpy.logical_not(ndarray.ravel(self._mask))]
return data
-
-
+
+
def compress(self, condition, axis=None, out=None):
"""Return a where condition is True.
If condition is a MaskedArray, missing values are considered as False.
-
+
Returns
-------
A MaskedArray object.
-
+
Notes
-----
- Please note the difference with compressed() !
+ Please note the difference with compressed() !
The output of compress has a mask, the output of compressed does not.
-
+
"""
# Get the basic components
(_data, _mask) = (self._data, self._mask)
@@ -2169,16 +2169,16 @@ masked_%(name)s(data = %(data)s,
Notes
-----
- The value returned is by default a biased estimate of the
+ The value returned is by default a biased estimate of the
true variance, since the mean is computed by dividing by N-ddof.
For the (more standard) unbiased estimate, use ddof=1 or.
- Note that for complex numbers the absolute value is taken before
+ Note that for complex numbers the absolute value is taken before
squaring, so that the result is always real and nonnegative.
"""
if self._mask is nomask:
# TODO: Do we keep super, or var _data and take a view ?
- return super(MaskedArray, self).var(axis=axis, dtype=dtype,
+ return super(MaskedArray, self).var(axis=axis, dtype=dtype,
ddof=ddof)
else:
cnt = self.count(axis=axis)-ddof
@@ -2213,17 +2213,17 @@ masked_%(name)s(data = %(data)s,
Notes
-----
- The value returned is by default a biased estimate of the
- true standard deviation, since the mean is computed by dividing
- by N-ddof. For the more standard unbiased estimate, use ddof=1.
- Note that for complex numbers the absolute value is taken before
+ The value returned is by default a biased estimate of the
+ true standard deviation, since the mean is computed by dividing
+ by N-ddof. For the more standard unbiased estimate, use ddof=1.
+ Note that for complex numbers the absolute value is taken before
squaring, so that the result is always real and nonnegative.
"""
dvar = self.var(axis,dtype,ddof=ddof)
if axis is not None or dvar is not masked:
dvar = sqrt(dvar)
return dvar
-
+
#............................................
def round(self, decimals=0, out=None):
result = self._data.round(decimals).view(type(self))
@@ -2564,7 +2564,7 @@ masked_%(name)s(data = %(data)s,
#........................
def tofile(self, fid, sep="", format="%s"):
raise NotImplementedError("Not implemented yet, sorry...")
-
+
#--------------------------------------------
# Pickling
def __getstate__(self):
@@ -2886,7 +2886,7 @@ def sort(a, axis=-1, kind='quicksort', order=None, endwith=True, fill_value=None
a = narray(a, copy=True, subok=True)
if axis is None:
a = a.flatten()
- axis = 0
+ axis = 0
if fill_value is None:
if endwith:
filler = minimum_fill_value(a)
diff --git a/numpy/ma/extras.py b/numpy/ma/extras.py
index a8dec0637..928ea9498 100644
--- a/numpy/ma/extras.py
+++ b/numpy/ma/extras.py
@@ -11,18 +11,18 @@ __version__ = '1.0'
__revision__ = "$Revision: 3473 $"
__date__ = '$Date: 2007-10-29 17:18:13 +0200 (Mon, 29 Oct 2007) $'
-__all__ = ['apply_along_axis', 'atleast_1d', 'atleast_2d', 'atleast_3d',
- 'average',
+__all__ = ['apply_along_axis', 'atleast_1d', 'atleast_2d', 'atleast_3d',
+ 'average',
'column_stack','compress_cols','compress_rowcols', 'compress_rows',
'count_masked',
'dot','dstack',
'expand_dims',
- 'flatnotmasked_contiguous','flatnotmasked_edges',
- 'hsplit','hstack',
+ 'flatnotmasked_contiguous','flatnotmasked_edges',
+ 'hsplit','hstack',
'mask_cols','mask_rowcols','mask_rows','masked_all','masked_all_like',
- 'median','mediff1d','mr_',
- 'notmasked_contiguous','notmasked_edges',
- 'row_stack',
+ 'median','mediff1d','mr_',
+ 'notmasked_contiguous','notmasked_edges',
+ 'row_stack',
'vstack',
]
@@ -262,7 +262,7 @@ def average(a, axis=None, weights=None, returned=False):
the size of a along the given axis.
If no weights are given, weights are assumed to be 1.
returned : bool
- Flag indicating whether a tuple (result, sum of weights/counts)
+ Flag indicating whether a tuple (result, sum of weights/counts)
should be returned as output (True), or just the result (False).
"""
@@ -417,7 +417,7 @@ def median(a, axis=0, out=None, overwrite_input=False):
else:
choice = slice(idx-1,idx+1)
return data[choice].mean(0)
- #
+ #
if overwrite_input:
if axis is None:
sorted = a.ravel()
@@ -432,7 +432,7 @@ def median(a, axis=0, out=None, overwrite_input=False):
else:
result = apply_along_axis(_median1D, axis, sorted)
return result
-
+
@@ -445,7 +445,7 @@ def compress_rowcols(x, axis=None):
- If axis is None, rows and columns are suppressed.
- If axis is 0, only rows are suppressed.
- If axis is 1 or -1, only columns are suppressed.
-
+
Parameters
----------
axis : int, optional
@@ -504,7 +504,7 @@ def mask_rowcols(a, axis=None):
axis : int, optional
Axis along which to perform the operation.
If None, applies to a flattened version of the array.
-
+
Returns
-------
a *pure* ndarray.
@@ -795,7 +795,7 @@ def notmasked_contiguous(a, axis=None):
axis : int, optional
Axis along which to perform the operation.
If None, applies to a flattened version of the array.
-
+
Returns
-------
a sorted sequence of slices (start index, end index).
diff --git a/numpy/ma/morestats.py b/numpy/ma/morestats.py
index 9816608b7..7dbc844b0 100644
--- a/numpy/ma/morestats.py
+++ b/numpy/ma/morestats.py
@@ -59,7 +59,7 @@ Returns
Notes
-----
The function is restricted to 2D arrays.
-
+
"""
def _hd_1D(data,prob,var):
"Computes the HD quantiles for a 1D array. Returns nan for invalid data."
@@ -114,7 +114,7 @@ Parameters
Axis along which to compute the quantiles. If None, use a flattened array.
var : boolean
Whether to return the variance of the estimate.
-
+
"""
result = hdquantiles(data,[0.5], axis=axis, var=var)
return result.squeeze()
@@ -137,7 +137,7 @@ Parameters
Notes
-----
The function is restricted to 2D arrays.
-
+
"""
def _hdsd_1D(data,prob):
"Computes the std error for 1D arrays."
@@ -192,7 +192,7 @@ Parameters
Confidence level of the intervals.
axis : int
Axis along which to cut. If None, uses a flattened version of the input.
-
+
"""
data = masked_array(data, copy=False)
trimmed = trim_both(data, proportiontocut=proportiontocut, axis=axis)
@@ -215,7 +215,7 @@ Parameters
Sequence of quantiles to compute.
axis : int
Axis along which to compute the quantiles. If None, use a flattened array.
-
+
"""
def _mjci_1D(data, p):
data = data.compressed()
@@ -345,7 +345,7 @@ def rank_data(data, axis=None, use_missing=False):
along the given axis.
If some values are tied, their rank is averaged.
- If some values are masked, their rank is set to 0 if use_missing is False,
+ If some values are masked, their rank is set to 0 if use_missing is False,
or set to the average rank of the unmasked values if use_missing is True.
Parameters
@@ -353,8 +353,8 @@ def rank_data(data, axis=None, use_missing=False):
data : sequence
Input data. The data is transformed to a masked array
axis : integer
- Axis along which to perform the ranking.
- If None, the array is first flattened. An exception is raised if
+ Axis along which to perform the ranking.
+ If None, the array is first flattened. An exception is raised if
the axis is specified for arrays with a dimension larger than 2
use_missing : boolean
Whether the masked values have a rank of 0 (False) or equal to the
diff --git a/numpy/ma/mrecords.py b/numpy/ma/mrecords.py
index 29b090540..5fcd8717e 100644
--- a/numpy/ma/mrecords.py
+++ b/numpy/ma/mrecords.py
@@ -142,7 +142,7 @@ class MaskedRecords(MaskedArray, object):
msg = "Mask and data not compatible: data size is %i, "+\
"mask size is %i."
raise MAError(msg % (nd, nm))
- copy = True
+ copy = True
if not keep_mask:
self.__setmask__(mask)
self._sharedmask = True
@@ -214,7 +214,7 @@ class MaskedRecords(MaskedArray, object):
def _getmask(self):
"""Return the mask of the mrecord.
A record is masked when all the fields are masked.
-
+
"""
if self.size > 1:
return self._fieldmask.view((bool_, len(self.dtype))).all(1)
@@ -415,7 +415,7 @@ The fieldname base is either `_data` or `_mask`."""
return ndarray.view(self, obj)
#......................................................
def filled(self, fill_value=None):
- """Returns an array of the same class as the _data part, where masked
+ """Returns an array of the same class as the _data part, where masked
values are filled with fill_value.
If fill_value is None, self.fill_value is used instead.
@@ -487,11 +487,11 @@ The fieldname base is either `_data` or `_mask`."""
self._fieldmask.tostring(),
self._fill_value,
)
- return state
+ return state
#
def __setstate__(self, state):
- """Restore the internal state of the masked array, for pickling purposes.
- ``state`` is typically the output of the ``__getstate__`` output, and is a
+ """Restore the internal state of the masked array, for pickling purposes.
+ ``state`` is typically the output of the ``__getstate__`` output, and is a
5-tuple:
- class name
@@ -570,8 +570,8 @@ def fromarrays(arraylist, dtype=None, shape=None, formats=None,
"""
datalist = [getdata(x) for x in arraylist]
masklist = [getmaskarray(x) for x in arraylist]
- _array = recfromarrays(datalist,
- dtype=dtype, shape=shape, formats=formats,
+ _array = recfromarrays(datalist,
+ dtype=dtype, shape=shape, formats=formats,
names=names, titles=titles, aligned=aligned,
byteorder=byteorder).view(mrecarray)
_array._fieldmask[:] = zip(*masklist)
@@ -629,8 +629,8 @@ def fromrecords(reclist, dtype=None, shape=None, formats=None, names=None,
if dtype is None:
dtype = reclist.dtype
reclist = reclist.tolist()
- mrec = recfromrecords(reclist, dtype=dtype, shape=shape, formats=formats,
- names=names, titles=titles,
+ mrec = recfromrecords(reclist, dtype=dtype, shape=shape, formats=formats,
+ names=names, titles=titles,
aligned=aligned, byteorder=byteorder).view(mrecarray)
# Set the fill_value if needed
if fill_value is not None:
@@ -805,5 +805,3 @@ if 1:
import cPickle
_ = cPickle.dumps(mbase)
mrec_ = cPickle.loads(_)
-
- \ No newline at end of file
diff --git a/numpy/ma/mstats.py b/numpy/ma/mstats.py
index 7dc5a7cc3..093215e30 100644
--- a/numpy/ma/mstats.py
+++ b/numpy/ma/mstats.py
@@ -33,9 +33,9 @@ __all__ = ['cov','meppf','plotting_positions','meppf','mquantiles',
def winsorize(data, alpha=0.2):
"""Returns a Winsorized version of the input array.
-
- The (alpha/2.) lowest values are set to the (alpha/2.)th percentile,
- and the (alpha/2.) highest values are set to the (1-alpha/2.)th
+
+ The (alpha/2.) lowest values are set to the (alpha/2.)th percentile,
+ and the (alpha/2.) highest values are set to the (1-alpha/2.)th
percentile.
Masked values are skipped.
@@ -44,7 +44,7 @@ def winsorize(data, alpha=0.2):
data : ndarray
Input data to Winsorize. The data is first flattened.
alpha : float
- Percentage of total Winsorization: alpha/2. on the left,
+ Percentage of total Winsorization: alpha/2. on the left,
alpha/2. on the right
"""
@@ -57,8 +57,8 @@ def winsorize(data, alpha=0.2):
#..............................................................................
def trim_both(data, proportiontocut=0.2, axis=None):
- """Trims the data by masking the int(trim*n) smallest and int(trim*n)
- largest values of data along the given axis, where n is the number
+ """Trims the data by masking the int(trim*n) smallest and int(trim*n)
+ largest values of data along the given axis, where n is the number
of unmasked values.
Parameters
@@ -66,11 +66,11 @@ def trim_both(data, proportiontocut=0.2, axis=None):
data : ndarray
Data to trim.
proportiontocut : float
- Percentage of trimming. If n is the number of unmasked values
+ Percentage of trimming. If n is the number of unmasked values
before trimming, the number of values after trimming is:
(1-2*trim)*n.
axis : int
- Axis along which to perform the trimming.
+ Axis along which to perform the trimming.
If None, the input array is first flattened.
Notes
@@ -99,7 +99,7 @@ def trim_both(data, proportiontocut=0.2, axis=None):
#..............................................................................
def trim_tail(data, proportiontocut=0.2, tail='left', axis=None):
- """Trims the data by masking int(trim*n) values from ONE tail of the
+ """Trims the data by masking int(trim*n) values from ONE tail of the
data along the given axis, where n is the number of unmasked values.
Parameters
@@ -107,16 +107,16 @@ def trim_tail(data, proportiontocut=0.2, tail='left', axis=None):
data : ndarray
Data to trim.
proportiontocut : float
- Percentage of trimming. If n is the number of unmasked values
- before trimming, the number of values after trimming is
+ Percentage of trimming. If n is the number of unmasked values
+ before trimming, the number of values after trimming is
(1-trim)*n.
tail : string
- Trimming direction, in ('left', 'right').
- If left, the ``proportiontocut`` lowest values are set to the
- corresponding percentile. If right, the ``proportiontocut``
+ Trimming direction, in ('left', 'right').
+ If left, the ``proportiontocut`` lowest values are set to the
+ corresponding percentile. If right, the ``proportiontocut``
highest values are used instead.
axis : int
- Axis along which to perform the trimming.
+ Axis along which to perform the trimming.
If None, the input array is first flattened.
Notes
@@ -158,7 +158,7 @@ def trim_tail(data, proportiontocut=0.2, tail='left', axis=None):
#..............................................................................
def trimmed_mean(data, proportiontocut=0.2, axis=None):
- """Returns the trimmed mean of the data along the given axis.
+ """Returns the trimmed mean of the data along the given axis.
Trimming is performed on both ends of the distribution.
Parameters
@@ -169,7 +169,7 @@ def trimmed_mean(data, proportiontocut=0.2, axis=None):
Proportion of the data to cut from each side of the data .
As a result, (2*proportiontocut*n) values are actually trimmed.
axis : int
- Axis along which to perform the trimming.
+ Axis along which to perform the trimming.
If None, the input array is first flattened.
"""
@@ -188,7 +188,7 @@ def trimmed_stde(data, proportiontocut=0.2, axis=None):
Proportion of the data to cut from each side of the data .
As a result, (2*proportiontocut*n) values are actually trimmed.
axis : int
- Axis along which to perform the trimming.
+ Axis along which to perform the trimming.
If None, the input array is first flattened.
Notes
@@ -222,7 +222,7 @@ median along the given axis.
data : ndarray
Data to trim.
axis : int
- Axis along which to perform the trimming.
+ Axis along which to perform the trimming.
If None, the input array is first flattened.
"""
diff --git a/numpy/ma/tests/test_core.py b/numpy/ma/tests/test_core.py
index e1d4048a8..bdbe896e7 100644
--- a/numpy/ma/tests/test_core.py
+++ b/numpy/ma/tests/test_core.py
@@ -848,7 +848,7 @@ class TestMA(NumpyTestCase):
assert_equal(xf.dtype, float_)
assert_equal(xs.data, ['A', 'b', 'pi'])
assert_equal(xs.dtype, '|S3')
-
+
#...............................................................................
diff --git a/numpy/ma/tests/test_extras.py b/numpy/ma/tests/test_extras.py
index 2e1eebb04..fe0ef3b2e 100644
--- a/numpy/ma/tests/test_extras.py
+++ b/numpy/ma/tests/test_extras.py
@@ -324,7 +324,7 @@ class TestApplyAlongAxis(NumpyTestCase):
return b[1]
xa = apply_along_axis(myfunc,2,a)
assert_equal(xa,[[1,4],[7,10]])
-
+
class TestMedian(NumpyTestCase):
def __init__(self, *args, **kwds):
NumpyTestCase.__init__(self, *args, **kwds)
@@ -333,7 +333,7 @@ class TestMedian(NumpyTestCase):
"Tests median w/ 2D"
(n,p) = (101,30)
x = masked_array(numpy.linspace(-1.,1.,n),)
- x[:10] = x[-10:] = masked
+ x[:10] = x[-10:] = masked
z = masked_array(numpy.empty((n,p), dtype=numpy.float_))
z[:,0] = x[:]
idx = numpy.arange(len(x))
@@ -352,8 +352,8 @@ class TestMedian(NumpyTestCase):
assert_equal(median(x,0),[[99,10],[11,99],[13,14]])
x = numpy.ma.arange(24).reshape(4,3,2)
x[x%5==0] = masked
- assert_equal(median(x,0), [[12,10],[8,9],[16,17]])
-
+ assert_equal(median(x,0), [[12,10],[8,9],[16,17]])
+
###############################################################################
#------------------------------------------------------------------------------
diff --git a/numpy/ma/tests/test_mrecords.py b/numpy/ma/tests/test_mrecords.py
index 2f3931878..cb550a9aa 100644
--- a/numpy/ma/tests/test_mrecords.py
+++ b/numpy/ma/tests/test_mrecords.py
@@ -41,7 +41,7 @@ class TestMRecords(NumpyTestCase):
ddtype = [('a',int),('b',float),('c','|S8')]
mask = [0,1,0,0,1]
self.base = ma.array(zip(ilist,flist,slist), mask=mask, dtype=ddtype)
-
+
def test_byview(self):
"Test creation by view"
base = self.base
@@ -69,7 +69,7 @@ class TestMRecords(NumpyTestCase):
assert_equal(mbase_first.mask, nomask)
assert_equal(mbase_first._fieldmask.item(), (False, False, False))
assert_equal(mbase_first['a'], mbase['a'][0])
- mbase_last = mbase[-1]
+ mbase_last = mbase[-1]
assert isinstance(mbase_last, mrecarray)
assert_equal(mbase_last.dtype, mbase.dtype)
assert_equal(mbase_last.tolist(), (None,None,None))
@@ -87,7 +87,7 @@ class TestMRecords(NumpyTestCase):
assert_equal(getattr(mbase_sl,field), base[:2][field])
def test_set_fields(self):
- "Tests setting fields."
+ "Tests setting fields."
base = self.base.copy()
mbase = base.view(mrecarray)
mbase = mbase.copy()
@@ -101,7 +101,7 @@ class TestMRecords(NumpyTestCase):
assert_equal(mbase['a']._data, [1]*5)
assert_equal(ma.getmaskarray(mbase['a']), [0]*5)
assert_equal(mbase._mask, [False]*5)
- assert_equal(mbase._fieldmask.tolist(),
+ assert_equal(mbase._fieldmask.tolist(),
np.array([(0,0,0),(0,1,1),(0,0,0),(0,0,0),(0,1,1)],
dtype=bool))
# Set a field to mask ........................
@@ -109,7 +109,7 @@ class TestMRecords(NumpyTestCase):
assert_equal(mbase.c.mask, [1]*5)
assert_equal(ma.getmaskarray(mbase['c']), [1]*5)
assert_equal(ma.getdata(mbase['c']), ['N/A']*5)
- assert_equal(mbase._fieldmask.tolist(),
+ assert_equal(mbase._fieldmask.tolist(),
np.array([(0,0,1),(0,1,1),(0,0,1),(0,0,1),(0,1,1)],
dtype=bool))
# Set fields by slices .......................
@@ -129,12 +129,12 @@ class TestMRecords(NumpyTestCase):
assert_equal(ma.getmaskarray(mbase['b']), [1]*5)
assert_equal(mbase['a']._mask, mbase['b']._mask)
assert_equal(mbase['a']._mask, mbase['c']._mask)
- assert_equal(mbase._fieldmask.tolist(),
+ assert_equal(mbase._fieldmask.tolist(),
np.array([(1,1,1)]*5, dtype=bool))
# Delete the mask ............................
mbase._mask = nomask
assert_equal(ma.getmaskarray(mbase['c']), [0]*5)
- assert_equal(mbase._fieldmask.tolist(),
+ assert_equal(mbase._fieldmask.tolist(),
np.array([(0,0,0)]*5, dtype=bool))
#
def test_set_mask_fromarray(self):
@@ -154,7 +154,7 @@ class TestMRecords(NumpyTestCase):
def test_set_mask_fromfields(self):
mbase = self.base.copy().view(mrecarray)
#
- nmask = np.array([(0,1,0),(0,1,0),(1,0,1),(1,0,1),(0,0,0)],
+ nmask = np.array([(0,1,0),(0,1,0),(1,0,1),(1,0,1),(0,0,0)],
dtype=[('a',bool),('b',bool),('c',bool)])
mbase.mask = nmask
assert_equal(mbase.a.mask, [0,0,1,1,0])
@@ -240,8 +240,8 @@ class TestMRecords(NumpyTestCase):
_b = ma.array([1.1,2.2,3.3],mask=[0,0,1],dtype=float)
_c = ma.array(['one','two','three'],mask=[0,0,1],dtype='|S8')
ddtype = [('a',int),('b',float),('c','|S8')]
- mrec = fromarrays([_a,_b,_c], dtype=ddtype,
- fill_value=(99999,99999.,'N/A'))
+ mrec = fromarrays([_a,_b,_c], dtype=ddtype,
+ fill_value=(99999,99999.,'N/A'))
mrecfilled = mrec.filled()
assert_equal(mrecfilled['a'], np.array((1,2,99999), dtype=int))
assert_equal(mrecfilled['b'], np.array((1.1,2.2,99999.), dtype=float))
@@ -253,8 +253,8 @@ class TestMRecords(NumpyTestCase):
_b = ma.array([1.1,2.2,3.3],mask=[0,0,1],dtype=float)
_c = ma.array(['one','two','three'],mask=[1,0,0],dtype='|S8')
ddtype = [('a',int),('b',float),('c','|S8')]
- mrec = fromarrays([_a,_b,_c], dtype=ddtype,
- fill_value=(99999,99999.,'N/A'))
+ mrec = fromarrays([_a,_b,_c], dtype=ddtype,
+ fill_value=(99999,99999.,'N/A'))
#
assert_equal(mrec.tolist(),
[(1,1.1,None),(2,2.2,'two'),(None,None,'three')])
@@ -272,11 +272,11 @@ class TestMRecordsImport(NumpyTestCase):
_b = ma.array([1.1,2.2,3.3],mask=[0,0,1],dtype=float)
_c = ma.array(['one','two','three'],mask=[0,0,1],dtype='|S8')
ddtype = [('a',int),('b',float),('c','|S8')]
- mrec = fromarrays([_a,_b,_c], dtype=ddtype,
- fill_value=(99999,99999.,'N/A'))
+ mrec = fromarrays([_a,_b,_c], dtype=ddtype,
+ fill_value=(99999,99999.,'N/A'))
nrec = recfromarrays((_a.data,_b.data,_c.data), dtype=ddtype)
self.data = (mrec, nrec, ddtype)
-
+
def test_fromarrays(self):
_a = ma.array([1,2,3],mask=[0,0,1],dtype=int)
_b = ma.array([1.1,2.2,3.3],mask=[0,0,1],dtype=float)
@@ -284,8 +284,8 @@ class TestMRecordsImport(NumpyTestCase):
(mrec, nrec, _) = self.data
for (f,l) in zip(('a','b','c'),(_a,_b,_c)):
assert_equal(getattr(mrec,f)._mask, l._mask)
-
-
+
+
def test_fromrecords(self):
"Test construction from records."
(mrec, nrec, ddtype) = self.data
@@ -300,7 +300,7 @@ class TestMRecordsImport(NumpyTestCase):
_mrec = fromrecords(nrec)
assert_equal(_mrec.dtype, mrec.dtype)
for field in _mrec.dtype.names:
- assert_equal(getattr(_mrec, field), getattr(mrec._data, field))
+ assert_equal(getattr(_mrec, field), getattr(mrec._data, field))
#
_mrec = fromrecords(nrec.tolist(), names='c1,c2,c3')
assert_equal(_mrec.dtype, [('c1',int),('c2',float),('c3','|S5')])
@@ -311,7 +311,7 @@ class TestMRecordsImport(NumpyTestCase):
assert_equal(_mrec.dtype, mrec.dtype)
assert_equal_records(_mrec._data, mrec.filled())
assert_equal_records(_mrec._fieldmask, mrec._fieldmask)
-
+
def test_fromrecords_wmask(self):
"Tests construction from records w/ mask."
(mrec, nrec, ddtype) = self.data
@@ -328,7 +328,7 @@ class TestMRecordsImport(NumpyTestCase):
assert_equal_records(_mrec._data, mrec._data)
assert_equal(_mrec._fieldmask.tolist(), mrec._fieldmask.tolist())
#
- _mrec = fromrecords(nrec.tolist(), dtype=ddtype,
+ _mrec = fromrecords(nrec.tolist(), dtype=ddtype,
mask=mrec._fieldmask.tolist())
assert_equal_records(_mrec._data, mrec._data)
assert_equal(_mrec._fieldmask.tolist(), mrec._fieldmask.tolist())
diff --git a/numpy/ma/testutils.py b/numpy/ma/testutils.py
index 4ea49379f..c4722f940 100644
--- a/numpy/ma/testutils.py
+++ b/numpy/ma/testutils.py
@@ -216,4 +216,4 @@ def assert_mask_equal(m1, m2):
assert_array_equal(m1, m2)
if __name__ == '__main__':
- pass \ No newline at end of file
+ pass