| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
|
|
|
|
| |
This reverts commit 7141f40b58ed1e7071cde78ab7bc8ab37e9c5983,
reversing changes made to 8fa6e3bef26a6d4a2c92f2824129aa4409be2590.
The original broke some pandas tests. The current plan to get this
in is
* reversion
* issue FutureWarning in 1.11 and 1.12
* make the change in 1.13.
|
| |
|
|
|
|
|
|
|
|
| |
Adds the 'order' parameter to the __new__ override
in MaskedArray construction, enabling it to be enforced
in methods like np.ma.core.array and np.ma.core.asarray.
Closes gh-6646.
|
|
|
|
|
|
|
|
|
| |
Now, NaT compares like NaN:
- NaT != NaT -> True
- NaT == NaT (and all other comparisons) -> False
We discussed this on the mailing list back in October:
https://mail.scipy.org/pipermail/numpy-discussion/2015-October/073968.html
|
|\
| |
| |
| |
| | |
gerritholl/structured_multidim_masked_array_fillvalue
BUG/TST: Fix for #6723 including test: force fill_value.ndim==0
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Fix issue #6723. Given an exotic masked structured array, where one of
the fields has a multidimensional dtype, make sure that, when accessing
this field, the fill_value still makes sense. As it stands prior to this
commit, the fill_value will end up being multidimensional, possibly with
a shape incompatible with the mother array, which leads to broadcasting
errors in methods such as .filled(). This commit uses the first element
of this multidimensional fill value as the new fill value. When more
than one unique value existed in fill_value, a warning is issued.
Also add a test to verify that fill_value.ndim remains 0 after indexing.
|
| | |
|
|\ \
| | |
| | | |
MAINT: Simplify some tests using temppath context manager.
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
This replaces code of the pattern
```
fd, name = tempfile.mkstemp(...)
os.close(fd)
try:
do stuff with name
finally:
os.remove(name)
```
with
```
with temppath() as name:
do stuff with name
```
A few more complicated cases are also handled. The remains some
particularly gnarly code the could probably be refactored to use
temppath, but that is a more demanding project.
|
|/ / |
|
| | |
|
| |
| |
| |
| | |
Closes gh-6863.
|
| | |
|
| |
| |
| |
| |
| |
| |
| | |
The test currently uses an `<i8` type which is converted to a Python
long integer when running on a 32 bit system with Python 2. That changes
the string printed by appending `L` to the printed integer value and
results in a failed test.
|
|/ |
|
|\
| |
| |
| |
| | |
gerritholl/structured_multidim_masked_array_mvoid_alt
BUG/TST: Fix for #6724, make numpy.ma.mvoid consistent with numpy.void
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Make indexing on numpy.ma.mvoid consistent with indexing on numpy.void.
Changes behaviour in rare cases (see below). Fixes #6724. Sometimes,
indexing ma.mvoid results in a non-scalar mask. For example, dimension
increases if indexing with a multi-dimensional field. Previously, this
led to a ValueError (truth value ambiguous). With this commit, indexing
now returns an ma.masked_array so that there is no loss of information.
Note that there is a precedence for returning from void to array. Z =
zeros((2,), dtype="(2,)i2,(2,)i2"), then Z[0] is a void, but Z[0][0]
and Z[0]["f1"] are array. This commit therefore implements behaviouk
such that numpy.ma.mvoid is consistent with numpy.void.
Also adds a related test.
The behaviour changes in cases where for a masked array `X`, X.dtype["A"]
is multidimensional but size 1, such as in the example below. Any case
where X.dtype["A"] is multidimensional but with size>1 would previously
fail.
Old behaviour:
In [15]: X = ma.masked_array(data=[([0],)], mask=[([False],)],
dtype=[("A", "(1,1)i2", (1,1))])
In [16]: X[0]["A"]
Out[16]: array([[[[0]]]], dtype=int16)
In [17]: X = ma.masked_array(data=[([0],)], mask=[([True],)],
dtype=[("A", "(1,1)i2", (1,1))])
In [18]: X[0]["A"]
Out[18]: masked
New behaviour:
In [1]: X = ma.masked_array(data=[([0],)], mask=[([False],)],
dtype=[("A", "(1,1)i2", (1,1))])
In [2]: X[0]["A"]
Out[2]:
masked_array(data =
[[[[0]]]],
mask =
[[[[False]]]],
fill_value = [[[[16959]]]])
In [3]: X = ma.masked_array(data=[([0],)], mask=[([True],)],
dtype=[("A", "(1,1)i2", (1,1))])
In [4]: X[0]["A"]
Out[4]:
masked_array(data =
[[[[--]]]],
mask =
[[[[ True]]]],
fill_value = [[[[16959]]]])
The new behaviour is more consistent with indexing the data themselves:
In [7]: X.data[0]["A"]
Out[7]: array([[[[0]]]], dtype=int16)
In theory, this change in behaviour can break code, but I would consider
it very unlikely.
|
|/
|
|
|
|
| |
Fix #6760. In ma.core._recursive_make_descr, consider the case where a
subdtype does itself have named fields. This ensures the correct mask for
an array like `ma.zeros(2, dtype([("A", "(2,2)i1,(2,2)i1", (2,2))]))`.
|
|\
| |
| | |
ENH: Avoid memory peak when creating a MaskedArray with mask=True/False.
|
| | |
|
|/
|
|
|
|
| |
Fix representation of a structured masked array with dimension zero.
The effect of representing a masked array with dimension zero is now
similar to respresenting an mvoid. This commit fixes #6729.
|
|
|
|
|
|
|
|
|
|
| |
When the mask argument was nomask, commit 8da9c71 changed the behavior
to depend on shrink=True as well, resulting in array(False) false being
returned when shrink=True, which in turn led to bugs because nomask is a
singleton and is detected by `mask is nomask`. That dectection fails
when nomask is replaced by array(False).
Closes #6667.
|
|
|
|
|
| |
Test that ma.dot always returns a masked array.
Test basic that the new out parameter in ma.dot works.
|
|
|
|
|
|
|
|
|
|
|
| |
Replace the _arraymethod class in ma.core with a function factory which
returns class method wrappers around basic array methods. These methods are
bound to the MaskedArray instance and are immutable.
Previously _arraymethod was a class which would incorrectly operate on the
MaskedArray object which last accessed the particular named function.
closes #5247
|
|\
| |
| | |
BUG: scalar argument to ma.atleast_* return arrays
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
The np.ma.atleast_1d, np.ma.atleast_2d, np.ma.atleast_3d and np.ma.diagflat
function return arrays when given a scalar in the same manner as their non-ma
counterparts. Previously these function would return None.
Additionally, the np.ma vstack, row_stack, hstack, column_stack, dstack, and
hsplit functions now raise an expection when given a scalar argument.
closes #3367
|
|/
|
|
|
|
|
|
| |
When called with the shrink parameter set to False, np.ma.masked_values
will create a False filled array mask and not shrink the mask.
Previously the mask would be shrunk to a single False scalar.
closes #2674
|
|\
| |
| | |
BUG: ma.put expands nomask
|
| |
| |
| |
| |
| |
| |
| | |
Previously when put was used on a MaskedArray with nomask the mask would be
incorrectly set to the mask of the values argument.
closes #6425
|
|/
|
|
|
|
| |
The worst case of alternating masked iterated all boundaries and sliced
half away, improve this by only iterating the needed half of the
boundary index array.
|
|\
| |
| | |
BUG: Fixed a bug with string representation of masked structured arrays
|
| |
| |
| |
| |
| | |
This fixes a bug that caused the string representation of masked structured array rows with multi-dimensional columns to fail (numpy/numpy#6019), and includes a regression test.
Since __repr__ suffered from a similar bug, and since previously __repr__ returned the same as __str__ for mvoid, we now set __repr__ to reference the same method as __str__.
|
| |
| |
| |
| |
| |
| |
| | |
numpy.ma.round returns a scalar or np.ma.masked when called with a zero
dimensional array. This behavior is consistent with numpy.round.
closes #2244
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
numpy.ma.empty, zeros, ones, etc can be called using only keyword arguments
without a positional argument. Previously a single positional argument was
required.
For example:
np.ma.zeros(shape=(10, ))
closes #6106
|
| | |
|
| | |
|
|/
|
|
|
|
|
|
| |
Also fix "*" imports.
The formatting of test arrays is not fixed for multiple spaces following
"," and other violations that are common in tests. To be precise, E241
and E201 are added to the errors that are excluded.
|
|
|
|
|
|
|
|
|
|
|
|
| |
Viewing an ndarray as a np.recarray now automatically converts
the dtype to np.record.
This commit also fixes assignment to MaskedArray's dtype attribute,
fixes the repr of recarrays with non-structured dtype, and removes
recarray.view so that viewing a recarray as a non-structured dtype
no longer converts to ndarray type.
Fixes #3581
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
For a masked array holding objects that themselves are arrays, when selecting a
single item, it is treated as if it were a slice of the array and an attempt is
made to set its mask. This was always a bug, but it become visible with a
recent change to `MaskedArray.__getitem__` (gh-4586) where it is attempted to
change the shape of the mask. With this PR, this case gets special treatment
in that the object is made into a Masked Array with a full set mask.
(A previous attempt to do the perhaps more logical think and just return
`masked` caused quite a few errors in astropy.io.votable; it seemed it was
not worth breaking backwards compatibility that much).
Test case that now works but used to fail:
```
mx1 = MaskedArray([1.], mask=[True])
mx2 = MaskedArray([1., 2.])
mx = MaskedArray([mx1, mx2], mask=[False, True])
mx[0]
```
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
ndarray special methods like __add__ have a special case where if the
right argument is not an ndarray or subclass, and it has higher
__array_priority__ than the left argument, then we return
NotImplemented and let the right argument handle the operation.
ufuncs have traditionally had a similar but different special case,
where if it's a 2 input - 1 output ufunc, and the right argument is
not an ndarray (exactly, subclasses don't count), and when converted
to an ndarray ends up as an object array (presumably b/c it doesn't
have a meaningful coercion route, though who knows), and it has a
higher __array_priority__ than the left argument AND it has a
__r<operation>__ attribute, then they return NotImplemented.
In practice this latter special case is not used by regular ndarrays,
b/c anytime it would need to be triggered, the former special case
triggers first and the ufunc is never called. However, numpy.ma did
not have the former special case, and was thus relying on the ufunc
special case. This commit adds the special case to the numpy.ma
special methods directly, so that they no longer depend on the quirky
ufunc behaviour.
It also cleans up the relevant test to things that actually should be
true in general, instead of just testing some implementation details.
|
|\
| |
| | |
ENH: Let MaskedArray getter, setter respect baseclass overrides
|
| | |
|
| |
| |
| |
| |
| | |
Fixes #5846 (If called with an empty array as first argument, the returned
array had dtype bool instead of the dtype of the input array)
|
|\ \
| | |
| | | |
ENH: Improve np.ma.compress_rowcols() performance, ENH: add compress_nd()
|
| |/
| |
| |
| | |
Provides a way to supress slices along an abitrary tuple of dimensions.
|
| |
| |
| |
| | |
Closes #5679.
|
| |
| |
| |
| |
| |
| | |
Add a test to TestMaskedArrayFunctions to verify that a masked
structures array created with masked_where has a structured mask. The
mask was previously unstructured, leading to bug #2972.
|
|/
|
|
| |
See issue #4452.
|
| |
|