summaryrefslogtreecommitdiff
path: root/numpy/core/multiarray.py
Commit message (Collapse)AuthorAgeFilesLines
* MAINT: Use `np._using_numpy2_behavior()` and initialize it in CSebastian Berg2023-02-101-2/+3
|
* ENH: Convert methods to vectorcall conversions (#23018)Pieter Eendebak2023-01-231-3/+3
| | | | | | | | | | | | Convert several methods to the vectorcall convention. The conversions give a performance improvement, see #20790 (comment) Some notes: * For vdot the METH_KEYWORDS was removed, as the C vdot method was positional only. * The add_docstring is converted with an additional check. It was parsed as if (!PyArg_ParseTuple(args, "OO!:add_docstring", &obj, &PyUnicode_Type, &str)), but there is no support for the ! in the npy_parse_arguments * CI was complaining about coverage of _get_ndarray_c_version. A test was added, but only to provide coverage * In function_base.py a redundant check in def place was removed Co-authored-by: Sebastian Berg <sebastian@sipsolutions.net>
* DOC: Fix gh-22990 by correcting docstring of result_typeOleksandr Pavlyk2023-01-101-1/+1
|
* DOC: Fix doc `numpy.<exception>` to `numpy.exceptions.<exception>`Sebastian Berg2022-12-061-3/+3
|
* Merge pull request #22313 from rossbar/deprecate-fastCopyAndTransposeMatti Picus2022-10-071-2/+2
|\ | | | | DEP: Deprecate fastCopyAndTranspose
| * DEP: fastCopyAndTranspose and PyArray_CopyAndTransposeRoss Barnowski2022-10-061-2/+2
| | | | | | | | | | | | | | | | Deprecate the fastCopyAndTranspose function from the Python API, and the underlying PyArray_CopyAndTranspose function from the C-API. Also removes an internal, private function _fastCopyAndTranspose which was the original Python wrapper around the C-function.
* | DOC: Add copyto example (#22292)dg31922022-09-261-0/+16
|/
* DOC: add links to `linalg` in docs of `dot` and `matmul` (#22002)Petar Mlinarić2022-07-181-3/+7
| | | Add links to `linalg` explaining BLAS
* API: Add leading underscore to `no_nep50_warning` and `get/set_promotion_state`Sebastian Berg2022-06-151-3/+4
|
* API: Expose `get_promotion_state` and `set_promotion_state`Sebastian Berg2022-06-151-1/+4
| | | | | We need to be able to query the state for testing, probably should be renamed before the end, but need to have something for now.
* DIC: Misc RST reformatting.Matthias Bussonnier2022-06-031-1/+1
| | | | | | | | | | | | | | | | | | | | | This contains various RST reformatting. One, moving `(C)` one line up, is specific to a bug in tree-sitter-rst that mis parses this section. Another is adding one black line for a similar reason where `..` is seen as section underline by tree-sitter-rst. This is some shuffling of section underline: try to be consitant, `=`, then `-`, then `~`, with this refactor there is also no more section that use backticks as underline. Note in particular that non-consitency of underline lead to a problem in datetime64 section where "weekmasks" (underlined with `-`) were actually a level-4 heading instead of a level 2 or 3 I guess, and thus were nested under the `busday_count()` section. You'll note also 2 formulas that are under double-quotes as they are not references.
* ENH: Add `_get_madvise_hugepage` functionJohn Kirkham2022-05-141-1/+1
| | | | | Provides a simple private function to query whether NumPy will try to use hugepages or not.
* MAINT: make np._from_dlpack publicTirth Patel2022-03-031-3/+3
|
* ENH: add a 'version' field to PyDataMem_Handlermattip2021-11-101-8/+8
|
* change from_dlpack to _dlpack, remove unused headermattip2021-11-021-8/+9
|
* ENH, TST: Add the from_dlpack method and test DLPack.Hameer Abbasi2021-11-021-4/+5
|
* ENH: Configurable allocator (#17582)Matti Picus2021-10-251-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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: Remove unused imports and unreachable code (#18762)Elisha Hollander2021-07-071-2/+0
| | | * Remove unnecessary imports and minor fixes
* MAINT: Remove `digitize` from `np.core.multiarray.__all__`Bas van Beek2021-06-131-1/+1
| | | | There is no `digitize` function in aforementioned namespace
* DOC: Mark a number of function arguments as positional-onlyBas van Beek2021-06-061-9/+9
|
* ENH: Use new argument parsing for array creation functionsSebastian Berg2021-03-181-1/+6
| | | | | | | | | | | | | | | | | | 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)
* DOC: Misc numpydoc format fixesMatthias Bussonnier2021-01-271-3/+3
| | | | | | | | | Via prototype docstring autoreformatter; and cherry-picked to mostly include spacing issues around colons in parameters and see also. When no space is present numpydoc tend to miss-parse those sections A couple of typos are fixed as well.
* DOC: Fix and extend the docstring for np.inner (#18002)Michal W. Tarnowski2020-12-161-6/+21
| | | | | | | | | | | | | | | | * DOC: fix the docstring for np.inner * DOC: extend the docstring for np.inner and add an example * DOC: update numpy/core/multiarray.py Co-authored-by: Eric Wieser <wieser.eric@gmail.com> * DOC: apply suggestions from code review Co-authored-by: Matti Picus <matti.picus@gmail.com> Co-authored-by: Eric Wieser <wieser.eric@gmail.com> Co-authored-by: Matti Picus <matti.picus@gmail.com>
* DEP: Finalize unravel_index `dims` alias for `shape` keywordSebastian Berg2020-12-021-4/+1
| | | | | The argument was renamed to `shape` and deprecated since NumPy 1.16, so the deprecation can now be finalized.
* Harmonize quoting in (ones/fill/zeros/empty)_like documentationserge-sans-paille2020-11-211-2/+2
|
* Fix copy-paste typo in empty_like documentation.serge-sans-paille2020-11-211-1/+1
|
* DOC: Typo in lexsort docstringandryandrew2020-10-201-1/+1
| | | ...it's rows... --> ...its rows...
* DOC: Fix a parameter type in the `putmask` docs (#17412)Bas van Beek2020-10-011-1/+1
|
* DOC: Fix syntax errors in docstrings for versionchanged, versionadded (#17338)Bradley Dice2020-09-171-2/+2
| | | * DOC: Fix typos in versionchanged.
* DOC: Fixup deprecation datesSebastian Berg2020-09-031-2/+2
|
* Apply suggestions from code reviewSebastian Berg2020-09-021-1/+1
| | | Co-authored-by: Eric Wieser <wieser.eric@gmail.com>
* ENH: Implement concatenate dtype and casting keyword argumentsSebastian Berg2020-09-021-2/+12
| | | | | | | Unfortunately, the casting was not consistent and sometimes used force casting (axis=None) while normally same kind casting was used. This thus deprecates the `force_casting` corner case, so that casting has to be provided in the future.
* Merge pull request #16532 from seberg/delete-sigint-handlingMatti Picus2020-07-171-1/+1
|\ | | | | BUG: Remove non-threadsafe sigint handling from fft calculation
| * BUG: Remove non-threadsafe sigint handling from fft calculationSebastian Berg2020-06-251-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The fft calculation is the only point in our code where this function is used. Allowing Ctrl+C, in FFT specifically used have more reasons, since before pocketfft, some array-sizes could lead to very large run-times. Pocketfft fixed that issue, and now FFT is not really any slower, faster, or memory hungry than any other NumPy operation so it feels it does not need this handling. Rather, if we can find a better solution, it should also be added to more functions. The reason for removal is that it is not only unsafe while the FFT is running (in theory). Multiple, threaded FFT run can easily leave the signal handler in a bad state, causing crashes if Ctrl+C (sigint) is given at any point after the call. It would be possible to patch that over, by only resetting the signal handler if we actually changed it (or even more complex tricks), or possibly only using this technique when on the main thread. But, all of these solutions seem to complicate things, when the main reason for why allowing sigint seems useful is gone with pocketfft.
* | DOC: cross-reference numpy.dot and numpy.linalg.multi_dotAndras Deak2020-06-211-0/+1
|/ | | | | Add linalg.multi_dot to the "See also" of numpy.dot, change dot to numpy.dot for linking in the "See also" of multi_dot.
* DOC: Fix documentation rendering,Matthias Bussonnier2020-05-191-1/+1
| | | | | | | | the => seem to be extra and rst seem to not interprete backtick with leading space as closing a directive, the the full line on text was put in a html pre-tag when building the docs. see current https://numpy.org/doc/stable/reference/generated/numpy.packbits.html
* Merge pull request #16197 from timhoffm/doc-stackSebastian Berg2020-05-151-5/+6
|\ | | | | DOC: Unify cross-references between array joining methods
| * DOC: Unify cross-references between array joining methodsTim Hoffmann2020-05-101-5/+6
| |
* | DOC: warn about runtime of shares_memoryPauli Virtanen2020-05-111-3/+34
|/ | | | | The function runtime is essentially not bounded unless max_work is set. Most users probably want to use `may_share_memory` instead.
* Fixup: Implement suggestions by MattiSebastian Berg2020-04-281-1/+1
|
* Merge pull request #12646 from shoyer/refguide-check-exceptionsMatti Picus2020-02-281-2/+3
|\ | | | | TST: check exception details in refguide_check.py
| * TST: check exception details in refguide_check.pyStephan Hoyer2019-01-011-2/+3
| | | | | | | | xref GH-12548
* | BUG, DOC: restore missing importmattip2020-02-131-0/+3
| |
* | MAINT: Clean up, mostly unused imports.Warren Weckesser2020-01-231-3/+0
| |
* | MAINT: resolve pyflake F403 'from module import *' usedMike Taves2020-01-231-2/+2
| | | | | | | | | | | | * For external modules, resolve imported members * Most internal relative modules were ignored or marked noqa: F403 * Convert a few internal absolute imports to relative imports
* | MAINT: Remove Python2 newbuffer getbufferSeth Troisi2020-01-051-2/+0
| |
* | MAINT: Remove unused int_asbufferJon Dufresne2020-01-041-1/+1
| | | | | | | | | | | | | | On Python 3, int_asbuffer throws NotImplementedError and goes unused internally. Fixes #12425
* | Merge pull request #13944 from eric-wieser/forbid-_add_newdocs-pythonEric Wieser2019-07-081-3/+6
|\ \ | | | | | | MAINT,BUG,DOC: Fix errors in _add_newdocs
| * | BUG: Add missing `np.core.multiarray._get_ndarray_c_version` functionEric Wieser2019-06-301-1/+1
| | | | | | | | | | | | | | | | | | This must have been lost in the multiarray / umath merge. Found by noticing that `add_newdocs` was being called on an object that does not exist.
| * | BUG: Remove items from `multiarray.__all__` which do not exist on python 3Eric Wieser2019-06-301-2/+5
| | | | | | | | | | | | | | | | | | Avoid using `_add_newdocs` if these functions do not exist. Leaving the version-checking here so that we can backport to 1.16