summaryrefslogtreecommitdiff
path: root/numpy/ma
Commit message (Collapse)AuthorAgeFilesLines
...
| * | BUG: fix `ma.average` not working well with nan weightsIvan Gonzalez2021-12-022-1/+27
| | | | | | | | | | | | If a weight is nan it behaves erratically. See the tests added.
* | | STY: Use subscriptable `collections.abc` types over the generic aliases in …Bas van Beek2021-12-232-3/+2
| | |
* | | STY: Use subscriptable `builtins` types over the generic aliases in `typing`Bas van Beek2021-12-234-10/+10
| | |
* | | DEP: remove NPY_ARRAY_UPDATEIFCOPY, deprecated in 1.14 (#20589)Matti Picus2021-12-181-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * DEP: remove NPY_ARRAY_UPDATEIFCOPY, deprecated in 1.14 * remove more UPDATEIFCOPY * typo: add missing comma * remove a few more UPDATEIFCOPY * Add release note * remove UPDATEIFCOPY from comment (from review)
* | | Fix sorting of int8/int16serge-sans-paille2021-12-121-0/+4
|/ / | | | | | | | | | | radix sort operates on unsigned types, but the key extractor needs to know the original type. Fix #20567
* | DOC: Update axis parameter for np.ma.{min,max}Yoon, Jee Seok2021-11-191-2/+8
| | | | | | | | | | `np.ma.min` and `np.ma.max` accepts `tuple of ints` for `axis` parameter; the documentation should add it. Furthuer, since the only depenency for `axis` parameter is [`result = self.filled(fill_value).min`](https://github.com/numpy/numpy/blob/b235f9e701e14ed6f6f6dcba885f7986a833743f/numpy/ma/core.py#L5700), which is essentially `np.ndarray.min`, the documentation for `axis` parameter should be same as `np.ndarray.min` (i.e., add [.. versionadded:: 1.7.0](https://github.com/numpy/numpy/blob/056abda14dab7fa8daf7a1ab44144aeb2250c216/numpy/core/fromnumeric.py#L2814)). Same goes for np.ma.max.
* | REV: Add MaskedArray creation from non nd-array back in (#20386)Greg Lucas2021-11-162-0/+48
| | | | | | | | | | | | | | | | | | | | | | | | * REV: Add MaskedArray creation from non nd-array back in This code path was removed in beacb39. This adds back in the MaskedArray portion of that commit. A test with a Quantity-like (non inherited, but still acts like a MaskedArray) class for this case. * Update numpy/ma/core.py Co-authored-by: Sebastian Berg <sebastian@sipsolutions.net>
* | ENH: Configurable allocator (#17582)Matti Picus2021-10-251-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fixes gh-17467. Adds a public struct to hold memory manipulation routines PyDataMem_Handler and two new API functions PyDataMem_SetHandler to replace the current routines with the new ones, and PyDataMem_GetHandlerName to get the string name of the current routines (either globally or for a specific ndarray object). This also changes the size of the ndarray object to hold the PyDataMem_Handler active when it was created so subsequent actions on its data memory will remain consistent. Tests and documentation are included. Along the way, I found some places in the code where the current policy is inconsistent (all data memory handling should have gone through npy_*_cache not PyDataMem_*) so even if this is rejected it might improve the cache handling. The PyDataMem_Handler has fields to override memcpy, these are currently not implemented: memcpy in the code base is untouched. I think this PR is invasive enough as-is, if desired memcpy can be handled in a follow-up PR. * ENH: add and use global configurable memory routines * ENH: add tests and a way to compile c-extensions from tests * fix allocation/free exposed by tests * DOC: document the new APIs (and some old ones too) * BUG: return void from FREE, also some cleanup * MAINT: changes from review * fixes from linter * setting ndarray->descr on 0d or scalars mess with FREE * make scalar allocation more consistent wrt np_alloc_cache * change formatting for sphinx * remove memcpy variants * update to match NEP 49 * ENH: add a python-level get_handler_name * ENH: add core.multiarray.get_handler_name * Allow closure-like definition of the data mem routines * Fix incompatible pointer warnings * Note PyDataMemAllocator and PyMemAllocatorEx differentiation Co-authored-by: Matti Picus <matti.picus@gmail.com> * Redefine default allocator handling * Always allocate new arrays using the current_handler * Search for the mem_handler name of the data owner * Sub-comparisons don't need a local mem_handler * Make the default_handler a valid PyDataMem_Handler * Fix PyDataMem_SetHandler description (NEP discussion) * Pass the allocators by reference * Implement allocator context-locality * Fix documentation, make PyDataMem_GetHandler return const * remove import of setuptools==49.1.3, doesn't work on python3.10 * Fix refcount leaks * fix function signatures in test * Return early on PyDataMem_GetHandler error (VOID_compare) * Add context/thread-locality tests, allow testing custom policies * ENH: add and use global configurable memory routines * ENH: add tests and a way to compile c-extensions from tests * fix allocation/free exposed by tests * DOC: document the new APIs (and some old ones too) * BUG: return void from FREE, also some cleanup * MAINT: changes from review * fixes from linter * setting ndarray->descr on 0d or scalars mess with FREE * make scalar allocation more consistent wrt np_alloc_cache * change formatting for sphinx * remove memcpy variants * update to match NEP 49 * ENH: add a python-level get_handler_name * ENH: add core.multiarray.get_handler_name * Allow closure-like definition of the data mem routines * Fix incompatible pointer warnings * Note PyDataMemAllocator and PyMemAllocatorEx differentiation Co-authored-by: Matti Picus <matti.picus@gmail.com> * Redefine default allocator handling * Always allocate new arrays using the current_handler * Search for the mem_handler name of the data owner * Sub-comparisons don't need a local mem_handler * Make the default_handler a valid PyDataMem_Handler * Fix PyDataMem_SetHandler description (NEP discussion) * Pass the allocators by reference * remove import of setuptools==49.1.3, doesn't work on python3.10 * fix function signatures in test * try to fix cygwin extension building * YAPF mem_policy test * Less empty lines, more comments (tests) * Apply suggestions from code review (set an exception and) Co-authored-by: Matti Picus <matti.picus@gmail.com> * skip test on cygwin * update API hash for changed signature * TST: add gc.collect to make sure cycles are broken * Implement thread-locality for PyPy Co-authored-by: Sebastian Berg <sebastian@sipsolutions.net> * Update numpy/core/tests/test_mem_policy.py Co-authored-by: Sebastian Berg <sebastian@sipsolutions.net> * fixes from review * update circleci config * fix test * make the connection between OWNDATA and having a allocator handle more explicit * improve docstring, fix flake8 for tests * update PyDataMem_GetHandler() from review * Implement allocator lifetime management * update NEP and add best-effort handling of error in PyDataMem_UserFREE * ENH: fix and test for blindly taking ownership of data * Update doc/neps/nep-0049.rst Co-authored-by: Elias Koromilas <elias.koromilas@gmail.com>
* | MAINT: Refactor reductions to use NEP 43 style dispatching/promotionSebastian Berg2021-10-111-1/+1
|/ | | | | | | | This also implements new promoters for the logical functions. The reasoning is that any logical function can always be handled by first casting to boolean without changing the meaning. This is true (unless the output is object), and already effectively used for `np.all`/`np.any`.
* MAINT: Remove encoding declarations: # -*- coding: utf-8 -*-Dimitri Papadopoulos2021-10-061-1/+0
| | | | In Python 3, the default source file encoding is UTF-8.
* Merge pull request #19899 from arunppsg/issue16751_add_note_to_docsMelissa Weber Mendonça2021-10-012-11/+83
|\ | | | | DOC: replace return type in np.ma.* docstring
| * TST: added tests for np.ma.ones and np.ma.zerosArun2021-09-221-3/+47
| |
| * MAINT: Addded variables to __all__Arun2021-09-201-2/+2
| |
| * DOC: replace return type in np.ma* docstringArun2021-09-201-6/+34
| |
* | ENH: Add spaces after punctuation in dtype repr/str. (#19686)Antony Lee2021-09-291-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Before: ``` In [1]: np.dtype({"names": ["a"], "formats": [int], "offsets": [2]}) Out[1]: dtype({'names':['a'], 'formats':['<i8'], 'offsets':[2], 'itemsize':10}) ``` After: ``` In [1]: np.dtype({"names": ["a"], "formats": [int], "offsets": [2]}) Out[1]: dtype({'names': ['a'], 'formats': ['<i8'], 'offsets': [2], 'itemsize': 10}) ``` * Allow switching back to old dtype printing format. * Add changelog.
* | MAINT: Fix typo in public APIDimitri Papadopoulos2021-09-284-7/+42
| | | | | | | | | | | | | | | | | | | | | | | | By keeping both variants of the keyowrd parameter, we achieve backwards compatibility. The old mispelled variant has been removed from the documentation, the new variant does appear in the documentation and using noth variants raises a TypeError. Additionally, the old variant can only be used as a keyword argument, not as a positional argument. Co-authored-by: Eric Wieser <wieser.eric@gmail.com>
* | REV: 8396026Dimitri Papadopoulos2021-09-283-6/+6
| | | | | | | | | | Revert delimitor -> delimiter as the parameter name is part of the public API. We'll find a different solution to fix that.
* | DOC: Typos found by codespellDimitri Papadopoulos2021-09-214-12/+12
|/
* MAINT: remove unused argument in private functionMarten van Kerkwijk2021-09-141-2/+2
|
* MAINT: revise OSError aliases (IOError, EnvironmentError)Mike Taves2021-09-021-2/+2
|
* BUG: fix a regression where a masked_array's mask wouldn't updateClément Robert2021-08-241-0/+9
| | | | | properly when indx was itself a masked_array instance. Closes #19721. See #19244 for context.
* Add check for when value is a np.maiameskild2021-08-241-1/+2
|
* Merge pull request #19244 from iameskild/fix_18951Matti Picus2021-08-132-2/+12
|\ | | | | BUG: Fix an issue wherein assigment to `np.ma.masked_array` ignores mask in index
| * Fix lint E225 complaintiameskild2021-06-141-1/+1
| |
| * added tests for 18951 fixImenRajhi2021-06-141-0/+7
| |
| * added tests for 18951 fixImenRajhi2021-06-141-7/+0
| |
| * added a test for condition assignment for masked arraysImenRajhi2021-06-121-0/+7
| |
| * Add check if __setitem__ indx is maiameskild2021-06-111-2/+5
| |
* | PERF: Avoid using `@recursive`.Antony Lee2021-08-031-12/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | None of the functions decorated with `@recursive` actually need to close over internal variables, so they can be lifted to become toplevel recursive functions which avoid the need for an `@recursive` decorator. (No change was made to the logic of any of the functions.) As it turns out, the `@recursive` decorator adds a lot of overhead: `python runtests.py --bench bench_io` reports a ~15-20% perf gain(!) for `loadtxt` from this PR. (`_recursive_mask_or` seems less likely to matter performance-wise, but I also lifted it out for good measure... and just deleted the decorator's implementation.)
* | ENH: Add `__path__` annotations to all sub-packagesBas van Beek2021-07-251-0/+1
| |
* | ENH: Add annotations for `<module>.test` objectsBas van Beek2021-07-251-0/+3
| |
* | Merge pull request #19102 from default-303/LGTM_unused_variablesMatti Picus2021-07-092-6/+0
|\ \ | | | | | | MAINT: Removed suitable unused variables shown in LGTM
| * | MAINT: Removed 'if' block which served no purpose in core.py and removed ↵default-3032021-05-261-7/+0
| | | | | | | | | | | | '_linalgRealType(t)' function from linalg.py
| * | MAINT: Added comments for future refrence in core.py and system_info.py - ↵default-3032021-05-261-1/+2
| | | | | | | | | | | | fixed Azure linter 'line too long' error
| * | MAINT: Added comments for future refrence in core.py and system_info.pydefault-3032021-05-261-0/+3
| | |
| * | MAINT: Removed suitable unused variables shown in LGTMdefault-3032021-05-263-5/+0
| | |
* | | ENH: Adding keepdims to np.argmin,np.argmax (#19211)Gagandeep Singh2021-07-072-6/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * keepdims added to np.argmin,np.argmax * Added release notes entry * tested for axis=None,keepdims=True * Apply suggestions from code review * updated interface * updated interface * API changed, implementation to be done * Added reshape approach to C implementation * buggy implementation without reshape * TestArgMax, TestArgMin fixed, comments added * Fixed for matrix * removed unrequired changes * fixed CI failure * fixed linting issue * PyArray_ArgMaxKeepdims now only modifies shape and strides * Comments added to PyArray_ArgMaxKeepdims * Updated implementation of PyArray_ArgMinKeepdims to match with PyArray_ArgMaxKeepdims * Testing complete for PyArray_ArgMinKeepdims and PyArray_ArgMaxKeepdims * PyArray_ArgMinWithKeepdims both keepdims=True and keepdims=False * matched implementation of PyArray_ArgMaxKeepdims and PyArray_ArgMinKeepdims * simplified implementation * Added missing comment * removed unwanted header * addressed all the reviews * Removing unwanted changes * fixed docs * Added new lines * restored annotations * parametrized test * Apply suggestions from code review Co-authored-by: Sebastian Berg <sebastian@sipsolutions.net> * keyword handling now done in np.argmin/np.argmax * corrected indendation * used with pytest.riases(ValueError) * fixed release notes * removed PyArray_ArgMaxWithKeepdims and PyArray_ArgMinWithKeepdims from public C-API * Apply suggestions from code review Co-authored-by: Eric Wieser <wieser.eric@gmail.com> * Apply suggestions from code review Co-authored-by: Eric Wieser <wieser.eric@gmail.com> Co-authored-by: Sebastian Berg <sebastian@sipsolutions.net> Co-authored-by: Eric Wieser <wieser.eric@gmail.com>
* | | MAINT: Remove unused imports and unreachable code (#18762)Elisha Hollander2021-07-072-2/+0
| | | | | | | | | * Remove unnecessary imports and minor fixes
* | | BUG: fix np.ma.MaskedArray.anom when input is masked (#19023)Constanza2021-06-272-3/+24
| | |
* | | Merge pull request #19135 from ganesh-k13/BUG_13236_remove_complex_floor_divideCharles Harris2021-06-231-15/+27
|\ \ \ | |_|/ |/| | BUG: Remove complex floor divide
| * | BUG, TST: Determine complex types using typecodesGanesh Kathiresan2021-05-301-2/+2
| | |
| * | TST: Changed TC to check for `TypeError` in floor divideGanesh Kathiresan2021-05-291-15/+27
| |/
* | DOC: replace np.ma functions' return types with `MaskedArray` (#18964)Pax2021-05-291-11/+77
|/ | | | | | Relevant issue: #16751 Co-authored-by: paxcodes <13646646+paxcodes@users.noreply.github.com> Co-authored-by: IrinaMaria <28827042+IrinaMaria@users.noreply.github.com>
* MAINT: removed unused imports listed in LGTMdefault-3032021-05-242-2/+0
|
* DEP: Ensure the string promotion FutureWarning is raisedSebastian Berg2021-05-121-1/+1
| | | | | | | | | | | | Promotion errors are currently ignored and instead we use `object` as dtype. This means that the FutureWarning is ignored when raised. It also means that there is no way to opt into "future" behaviour, although arguably, we may want to force `dtype=object` in any case if a promotion error occurred (or some signal at least). Closes gh-18721 Addresses gh-18425 (Does not actually fix it, but chances are we won't)
* BUG: fixed ma.average ignoring masked weights (#18960)Laura Martens2021-05-122-1/+18
| | | | | Closes #10438 Co-authored-by: mecopur <mecopur@outlook.com>
* BUG: fix np.ma.masked_where(copy=False) when input has no mask (#18967)Constanza2021-05-102-1/+14
| | | | | Fixes gh-18946
* ENH: Add improved placeholder annotations for `np.ma`Bas van Beek2021-05-054-224/+867
|
* Merge pull request #18642 from seberg/splitup-faster-argparsing-optimize-asarrayMatti Picus2021-03-212-3/+3
|\ | | | | ENH: Use new argument parsing for array creation functions
| * ENH: Use new argument parsing for array creation functionsSebastian Berg2021-03-182-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The array creation functions have the most to gain: 1. np.asarray is 4 times faster and commonly used. 2. Other functions are wrapped using __array_function__ in Python making it more difficult This commit (unfortunatly) has to do a few things: * Modify __array_function__ C-side dispatching to accomodate the fastcall argument convention. * Move asarray, etc. to C after removing all "fast paths" from np.array (simplifying the code) * Fixup imports, since asarray was imported directly in a few places * Replace some places where `np.array` was probably used for speed instead of np.asarray or similar. (or by accident in 1 or 2 places)