summaryrefslogtreecommitdiff
path: root/numpy/ma
Commit message (Collapse)AuthorAgeFilesLines
* MAINT: Fix some typos in a code string and commentsDongjoon Hyun2016-01-271-1/+1
|
* Revert "Merge pull request #7001 from shoyer/NaT-comparison"Charles Harris2016-01-162-2/+5
| | | | | | | | | | | | 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.
* TEST: Ignore `FutureWarning` if raised from running masked array operations.John Kirkham2016-01-151-0/+8
|
* DEP: Add warnings to `__getitem__` and `__setitem__` to point out the ↵John Kirkham2016-01-151-0/+17
| | | | behavior of `MaskedArray`'s masks is changing.
* BUG: Enforce order param for MaskedArray constructiongfyoung2016-01-152-16/+41
| | | | | | | | 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.
* TST, ENH: make all comparisons with NaT falseStephan Hoyer2016-01-142-5/+2
| | | | | | | | | 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
* Merge pull request #6728 from ↵ahaldane2016-01-122-0/+24
|\ | | | | | | | | gerritholl/structured_multidim_masked_array_fillvalue BUG/TST: Fix for #6723 including test: force fill_value.ndim==0
| * BUG/TST: Fix for #6723 including test: force fill_value.ndim==0Gerrit Holl2015-12-072-0/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* | BUG trace is not subclass aware, such that np.trace(ma) != ma.trace().Marten van Kerkwijk2016-01-061-0/+1
| |
* | DOC: Match Documentation to Behavior for MaskedArray.filledgfyoung2016-01-031-1/+5
| | | | | | | | Closes gh-6647.
* | Merge pull request #6886 from charris/use-temppathCharles Harris2016-01-021-10/+6
|\ \ | | | | | | MAINT: Simplify some tests using temppath context manager.
| * | MAINT: Simplify some tests using temppath context manager.Charles Harris2015-12-261-10/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* | | MAINT: Cleanup and spelling fixups in ma.core testsgfyoung2015-12-301-24/+2
| | |
* | | [TST] Refactor new raise_warnings logic for subpackage test suitesNathaniel J. Smith2015-12-301-3/+3
|/ /
* | MAINT: Remove commented out code blocksgfyoung2015-12-201-58/+0
| |
* | DOC: Use print only as function when print_function is imported from __future__gfyoung2015-12-193-41/+41
| | | | | | | | Closes gh-6863.
* | TST: Fix test_mvoid_multidim_print failures on Python 2.x for WindowsChristoph Gohlke2015-12-111-4/+4
| |
* | TST,BUG: Make test_mvoid_multidim_print work for 32 bit systems.Charles Harris2015-12-111-1/+1
| | | | | | | | | | | | | | 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.
* | MAINT: Replace assert with assert_(...) in some tests.Charles Harris2015-12-101-16/+16
|/
* Merge pull request #6763 from ↵Charles Harris2015-12-042-0/+20
|\ | | | | | | | | gerritholl/structured_multidim_masked_array_mvoid_alt BUG/TST: Fix for #6724, make numpy.ma.mvoid consistent with numpy.void
| * BUG/TST: Fix for #6724, make numpy.ma.mvoid consistent with numpy.voidGerrit Holl2015-12-032-0/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* | BUG/TST: Fix #6760 by correctly describing mask on nested subdtypesGerrit Holl2015-12-032-1/+8
|/ | | | | | 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))]))`.
* Merge pull request #6734 from saimn/ma-mask-memoryCharles Harris2015-12-012-7/+22
|\ | | | | ENH: Avoid memory peak when creating a MaskedArray with mask=True/False.
| * Add some tests for mask creation with mask=True or False.Simon Conseil2015-12-011-0/+9
| |
| * Test that the mask dtype if MaskType before using np.zeros/onesSimon Conseil2015-12-011-2/+2
| |
| * ENH: Avoid memory peak when creating a MaskedArray with mask=True/False (#6732).Simon Conseil2015-11-261-8/+14
| | | | | | | | | | | | When the `mask` parameter is set to True or False, create directly a `ndarray` of boolean instead of going inside `np.resize` which was causing of memory peak of ~15 times the size of the mask.
* | Merge pull request #6748 from saimn/ma-repr-memoryCharles Harris2015-12-011-3/+16
|\ \ | | | | | | ENH: Avoid memory peak and useless computations when printing a MaskedArray.
| * | Use integer division to avoid casting to int.Simon Conseil2015-12-021-1/+1
| | |
| * | Allow to change the maximum width with a class variable.Simon Conseil2015-12-011-4/+6
| | |
| * | ENH: Avoid memory peak and useless computations when printing a MaskedArray.Simon Conseil2015-11-281-3/+14
| |/ | | | | | | | | | | | | | | | | Ref #3544. When printing a `MaskedArray`, the whole array is converted to the object dtype, whereas only a few values are printed to screen. So the approach here is to cut the array and keep only a subset that it used for the string conversion. This way the output should not change.
* | BUG/TST: Fix for #6729Gerrit Holl2015-12-012-1/+13
|/ | | | | | 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.
* BUG: ma.make_mask should always return nomask for nomask argument.Charles Harris2015-11-112-4/+16
| | | | | | | | | | 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.
* TST: Add tests for ma.dot.Charles Harris2015-11-102-21/+37
| | | | | Test that ma.dot always returns a masked array. Test basic that the new out parameter in ma.dot works.
* BUG, MAINT: Refactor ma.dot function and the corresponding method.Charles Harris2015-11-102-162/+221
| | | | | | | | | | | | | The basic implementation of ma.dot is moved from the method to the function and the function itself is moved from extras.py to core.py on account of import complications. The mask_rowcols function from extras is also moved to core.py as it is needed by dot. For backwards compatibility, both functions are still exported in extras.__all__ and can be imported from that module. They are not included in part of core.__all__. An out parameter is also added to ma.dot. This PR also closes #6611.
* STY: Minor style fixups.Charles Harris2015-11-072-3/+6
| | | | | Fix some long lines and indentation in numpy/ma/core.py and numpy/ma/extras.py
* BUG: immutable _arraymethod function in ma.coreJonathan Helmus2015-10-292-45/+30
| | | | | | | | | | | 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
* Merge pull request #6537 from jjhelmus/ma_atleast_fixCharles Harris2015-10-212-4/+28
|\ | | | | BUG: scalar argument to ma.atleast_* return arrays
| * BUG: scalar argument to ma.atleast_* return arraysJonathan Helmus2015-10-202-4/+28
| | | | | | | | | | | | | | | | | | | | | | 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
* | BUG: ma.masked_values does not shrink mask if requestedJonathan Helmus2015-10-202-2/+7
|/ | | | | | | | 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
* Merge pull request #6432 from jjhelmus/fix_ma_putahaldane2015-10-122-9/+25
|\ | | | | BUG: ma.put expands nomask
| * BUG: ma.put expands nomaskJonathan Helmus2015-10-122-9/+25
| | | | | | | | | | | | | | 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
* | ENH: improve worst case of ma.clump_maskedJulian Taylor2015-10-082-18/+39
|/ | | | | | 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.
* Merge pull request #6094 from astrofrog/fix-gh-6019ahaldane2015-10-042-25/+43
|\ | | | | BUG: Fixed a bug with string representation of masked structured arrays
| * BUG: Fixed string representation of mvoid with multi-dimensional columnsThomas Robitaille2015-10-042-25/+43
| | | | | | | | | | 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__.
* | Merge pull request #6400 from jjhelmus/fix_ma_roundCharles Harris2015-10-042-4/+33
|\ \ | | | | | | BUG: numpy.ma.round works on zero dimensional arrays
| * | MAINT: More expressive if statement in np.ma.roundJonathan Helmus2015-10-041-1/+1
| | |
| * | BUG: numpy.ma.round works on zero dimensional arraysJonathan Helmus2015-10-022-2/+31
| | | | | | | | | | | | | | | | | | | | | 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
| * | STY: Remove trailing whitespace from numpy/ma/core.pyJonathan Helmus2015-10-021-2/+2
| | |
* | | DOC: typo: affectLars Buitinck2015-10-021-3/+3
|/ /
* | BUG: numpy.ma functions can be called with only keyword argumentsJonathan Helmus2015-09-242-2/+14
| | | | | | | | | | | | | | | | | | | | | | | | 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