| Commit message (Collapse) | Author | Age | Files | Lines |
| ... | |
| | | |
| | |
| | |
| | | |
If a weight is nan it behaves erratically. See the tests added.
|
| | | | |
|
| | | | |
|
| | | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
* 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)
|
| |/ /
| |
| |
| |
| |
| | |
radix sort operates on unsigned types, but the key extractor needs to know the
original type.
Fix #20567
|
| | |
| |
| |
| |
| | |
`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
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>
|
| | |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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>
|
| |/
|
|
|
|
|
|
| |
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`.
|
| |
|
|
| |
In Python 3, the default source file encoding is UTF-8.
|
| |\
| |
| | |
DOC: replace return type in np.ma.* docstring
|
| | | |
|
| | | |
|
| | | |
|
| | |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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.
|
| | |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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>
|
| | |
| |
| |
| |
| | |
Revert delimitor -> delimiter as the parameter name is part of the
public API. We'll find a different solution to fix that.
|
| |/ |
|
| | |
|
| | |
|
| |
|
|
|
| |
properly when indx was itself a masked_array instance.
Closes #19721. See #19244 for context.
|
| | |
|
| |\
| |
| | |
BUG: Fix an issue wherein assigment to `np.ma.masked_array` ignores mask in index
|
| | | |
|
| | | |
|
| | | |
|
| | | |
|
| | | |
|
| | |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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.)
|
| | | |
|
| | | |
|
| |\ \
| | |
| | | |
MAINT: Removed suitable unused variables shown in LGTM
|
| | | |
| | |
| | |
| | | |
'_linalgRealType(t)' function from linalg.py
|
| | | |
| | |
| | |
| | | |
fixed Azure linter 'line too long' error
|
| | | | |
|
| | | | |
|
| | | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
* 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>
|
| | | |
| | |
| | | |
* Remove unnecessary imports and minor fixes
|
| | | | |
|
| |\ \ \
| |_|/
|/| | |
BUG: Remove complex floor divide
|
| | | | |
|
| | |/ |
|
| |/
|
|
|
|
| |
Relevant issue: #16751
Co-authored-by: paxcodes <13646646+paxcodes@users.noreply.github.com>
Co-authored-by: IrinaMaria <28827042+IrinaMaria@users.noreply.github.com>
|
| | |
|
| |
|
|
|
|
|
|
|
|
|
|
| |
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)
|
| |
|
|
|
| |
Closes #10438
Co-authored-by: mecopur <mecopur@outlook.com>
|
| |
|
|
|
| |
Fixes gh-18946
|
| | |
|
| |\
| |
| | |
ENH: Use new argument parsing for array creation functions
|
| | |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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)
|