summaryrefslogtreecommitdiff
path: root/numpy/core/shape_base.py
Commit message (Collapse)AuthorAgeFilesLines
* MAINT: remove `NUMPY_EXPERIMENTAL_ARRAY_FUNCTION` env varRalf Gommers2023-03-121-11/+0
| | | | | | | | As discussed in https://mail.python.org/archives/list/numpy-discussion@python.org/thread/UKZJACAP5FUG7KP2AQDPE4P5ADNWLOHZ/ This flag was always meant to be temporary, and cleaning it up is long overdue.
* DEP: Finalize the non-sequence stacking deprecationSebastian Berg2023-01-171-18/+14
| | | | | | | | | The `__array_function__` API currently will exhaust iterators so we cannot accept sequences reasonably. Checking for `__getitem__` is presumably enough to reject that (and was what the deprecation used). Future changes could allow this again, although it is not a useful API anyway, since we have to materialize the iterable in any case.
* DOC: Clarify relationship between row_stack and vstack.Ross Barnowski2022-11-141-0/+2
|
* ENH: adding casting option to numpy.stack. (#21627)Jhonatan Cunha2022-06-081-11/+49
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | np.concatenate and np.stack are similar methods, but only np.concatenate has the casting option. This PR puts the casting option into the np.stack method to control what kind of data casting may occur Closes gh-20959 * ENH: adding casting option to numpy.stack. See #20959 * ENH: adding dtype option to numpy.stack. See #20959 * REV: removing auto-generated file loops_modulo.dispatch.c See numpy#20959 * REV: removing auto-generated file loops_modulo.dispatch.c See numpy#20959 * REV: removing inserted newlines See numpy#20959 Co-authored-by: alescrocaro <alescrocaro@gmail.com> Co-authored-by: JessePires <jesserocha@alunos.utfpr.edu.br> Co-authored-by: patriarka <matheussantanapatriarca2019@outlook.com> * DOC: inserting versionadded info in dtype and casting parameters. See numpy#20959 Co-authored-by: alescrocaro <alescrocaro@gmail.com> Co-authored-by: JessePires <jesserocha@alunos.utfpr.edu.br> Co-authored-by: patriarka <matheussantanapatriarca2019@outlook.com> * TST: writing tests to stack method with dtype and casting options See numpy#20959 Co-authored-by: alescrocaro <alescrocaro@gmail.com> Co-authored-by: JessePires <jesserocha@alunos.utfpr.edu.br> Co-authored-by: patriarka <matheussantanapatriarca2019@outlook.com> * DOC: adding upcoming_change file for new options casting and dtype in method stack. See numpy#20959 Co-authored-by: alescrocaro <alescrocaro@gmail.com> Co-authored-by: JessePires <jesserocha@alunos.utfpr.edu.br> Co-authored-by: patriarka <matheussantanapatriarca2019@outlook.com> * REV: reverting lint errors. See numpy#20959 Co-authored-by: alescrocaro <alescrocaro@gmail.com> Co-authored-by: JessePires <jesserocha@alunos.utfpr.edu.br> Co-authored-by: patriarka <matheussantanapatriarca2019@outlook.com> * DOC: inserting hstack and vstack methods in upcoming changes See numpy#20959 Co-authored-by: alescrocaro <alescrocaro@gmail.com> Co-authored-by: JessePires <jesserocha@alunos.utfpr.edu.br> Co-authored-by: patriarka <matheussantanapatriarca2019@outlook.com> * ENH: adding dtype and casting keyword arguments to numpy.vstack and numpy.hstack. See numpy#20959 Co-authored-by: alescrocaro <alescrocaro@gmail.com> Co-authored-by: JessePires <jesserocha@alunos.utfpr.edu.br> Co-authored-by: patriarka <matheussantanapatriarca2019@outlook.com> * TST: writing tests to vstack and hstack methods with dtype and casting keyword arguments. See numpy#20959 Co-authored-by: alescrocaro <alescrocaro@gmail.com> Co-authored-by: JessePires <jesserocha@alunos.utfpr.edu.br> Co-authored-by: patriarka <matheussantanapatriarca2019@outlook.com> * REV: reverting the 'out' option type in stack method. See numpy#20959 Co-authored-by: alescrocaro <alescrocaro@gmail.com> Co-authored-by: JessePires <jesserocha@alunos.utfpr.edu.br> Co-authored-by: patriarka <matheussantanapatriarca2019@outlook.com> * REV: Reverting out type changes in overload of shape_base.pyi file. See numpy#20959 Co-authored-by: alescrocaro <alescrocaro@gmail.com> Co-authored-by: jhonatancunha <jhonatancunha@alunos.utfpr.edu.br> Co-authored-by: patriarka <matheussantanapatriarca2019@outlook.com> * DOC: correcting some english erros in upcoming_changes file. See numpy#20959 Co-authored-by: alescrocaro <alescrocaro@gmail.com> Co-authored-by: JessePires <jesserocha@alunos.utfpr.edu.br> Co-authored-by: patriarka <matheussantanapatriarca2019@outlook.com> Co-authored-by: JessePires <jessepires2010@gmail.com> Co-authored-by: alescrocaro <alescrocaro@gmail.com> Co-authored-by: JessePires <jesserocha@alunos.utfpr.edu.br> Co-authored-by: patriarka <matheussantanapatriarca2019@outlook.com>
* DOC: improper doc syntax (markdown and imbalanced ticks). (#20944)Matthias Bussonnier2022-01-301-13/+11
| | | | | | | | | | | | | | | | | | Here are two modifications: The first one is the inclusion of markdown fence blocks in the middle of RST. While this is not really a problem for current documentation as this is a private function, it still makes other RST parser choke on this. In particular this is seen as a tile as it is a text line followed by a line of only backticks, and that makes my new project to show better docstrings in Jupyter fails. I can locally exclude this function, but while not fix it to show good examples ? Second, while grepping for triple backticks I found that there are a stray one in another place.
* ENH: Use new argument parsing for array creation functionsSebastian Berg2021-03-181-2/+1
| | | | | | | | | | | | | | | | | | 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-1/+1
| | | | | | | | | 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: Update examples in stack docstrings (#18054)daaawx2020-12-221-21/+21
| | | The numbers chosen in the stacking examples can make them difficult to interpret. I suggest using different numbers to make it unambiguous.
* Fix typo in shape_base (#17279)Yang Hau2020-09-091-1/+2
| | | concatate to concatenate
* DOC: Unify cross-references between array joining methodsTim Hoffmann2020-05-101-13/+16
|
* STY: use 'yield from <expr>' for simple cases (#15444)Mike Taves2020-01-271-2/+1
| | | | | | | | | This PR uses simple cases of PEP 380 to rewrite: for v in g: yield v into: yield from <expr>
* MAINT: Remove Python2 workaroundsSeth Troisi2020-01-231-8/+2
|
* MAINT: Remove unnecessary 'from __future__ import ...' statementsJon Dufresne2020-01-031-2/+0
| | | | | As numpy is Python 3 only, these import statements are now unnecessary and don't alter runtime behavior.
* Fix typosBrian Wignall2019-11-251-1/+1
|
* DOC: convert `None` to bare None or ``None``mattip2019-10-151-1/+1
|
* ENH: Always produce a consistent shape in the result of `argwhere`Eric Wieser2019-09-051-7/+8
| | | | | | Previously this would return 1d indices even though the array is zero-d. Note that using atleast1d inside numeric required an import change to avoid a circular import.
* MAINT: avoid nested dispatch in numpy.core.shape_base (#13634)Stephan Hoyer2019-06-121-7/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * MAINT: avoid nested dispatch in numpy.core.shape_base This is a partial reprise of the optimizations from GH-13585. The trade-offs here are about readability, performance and whether these functions automatically work on ndarray subclasses. You'll have to judge the readability costs for yourself, but I think this is pretty reasonable. Here are the performance numbers for three relevant functions with the following IPython script: import numpy as np x = np.array([1]) xs = [x, x, x] for func in [np.stack, np.vstack, np.block]: %timeit func(xs) | Function | Master | This PR | | --- | --- | --- | | `stack` | 6.36 µs ± 175 ns | 6 µs ± 174 ns | | `vstack` | 7.18 µs ± 186 ns | 5.43 µs ± 125 ns | | `block` | 15.1 µs ± 141 ns | 11.3 µs ± 104 ns | The performance benefit for `stack` is somewhat marginal (perhaps it should be dropped), but it's much more meaningful inside `vstack`/`hstack` and `block`, because these functions call other dispatched functions within a loop. For automatically working on ndarray subclasses, the main concern would be that by skipping dispatch with `concatenate`, subclasses that define `concatenate` won't automatically get implementations for `*stack` functions. (But I don't think we should consider ourselves obligated to guarantee these implementation details, as I write in GH-13633.) `block` also will not get an automatic implementation, but given that `block` uses two different code paths depending on argument values, this is probably a good thing, because there's no way the code path not involving `concatenate` could automatically work (it uses `empty()`). * MAINT: only remove internal use in np.block * MAINT: fixup comment on np.block optimization
* MAINT: speed up [hvd]stack by eliminating list comprehension. (#13697)Marten van Kerkwijk2019-06-011-2/+7
|
* MAINT: Misc. typo fixes (#13664)luzpaz2019-05-311-4/+4
| | | | | | * DOC, MAINT: Misc. typo fixes Found via `codespell`
* MAINT: Fixes tests with __array_function__ disabledStephan Hoyer2019-05-261-0/+11
|
* MAINT: fixed typo 'wtihout' from numpy/core/shape_base.pyMin ho Kim2019-05-011-1/+1
|
* DEV: cleanup imports and some assignments (from LGTM)mattip2019-03-171-1/+0
|
* DOC: reduce warnings when building, reword, tweak doc buildingmattip2019-02-281-3/+5
|
* ENH: __array_function__ updates for NumPy 1.17.0Stephan Hoyer2019-01-221-8/+0
| | | | | | | | | | - Always enable __array_function__ overrides. - Remove special cases for Python 2 compatibility. - Document these changes in 1.17.0-notes.rst. It will be good to see ASV numbers to understand the performance implications of these changes. If need be, we can speed up NumPy functions internally by using non-dispatched functions (with ``.__wrapped__``).
* ENH: refactor __array_function__ pure Python implementationStephan Hoyer2018-12-191-3/+4
|
* MAINT: address several reviewer commentsTyler Reddy2018-12-141-2/+2
|
* TST, DOC: enable refguide_checkTyler Reddy2018-12-141-16/+16
| | | | | | | | * ported the refguide_check module from SciPy for usage in NumPy docstring execution/ verification; added the refguide_check run to Azure Mac OS CI * adjusted NumPy docstrings such that refguide_check passes
* Use set litteralsRoman Yurchak2018-11-241-1/+1
|
* MAINT: more fixes for disabling overridesStephan Hoyer2018-11-101-0/+8
|
* MAINT: adjust stack deprecation warning per reviewStephan Hoyer2018-10-281-6/+5
|
* MAINT: warn when passing map to stack functions, tooStephan Hoyer2018-10-271-4/+4
|
* DEP: deprecate passing a generator to stack functionsStephan Hoyer2018-10-271-8/+19
| | | | | | Fixes gh-12263 We can't support generators with dispatch for ``__array_function__``.
* MAINT: set __module__ for more array_function_dispatch usesStephan Hoyer2018-10-261-1/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | I noticed a few more functions using ``array_function_dispatch`` where I had not set the module, using this script:: import types def check_module(module): for name in dir(module): item = getattr(module, name) if isinstance(item, types.FunctionType): print(f'{item.__module__}.{item.__name__}') >>> import numpy >>> check_module(numpy) ... Note that functions without overrides like ``numpy.ones`` still display the module in which they are defined, e.g., ``numpy.core.numeric.ones``. We should probably fix that, too, probably most cleanly adding a decorator that sets ``__module__``, e.g., def set_module(module): def decorator(func): func.__module__ = module return func return decorator ... @set_module('numpy') def ones(shape, dtype=None, order='C'): ...
* Merge branch 'master' into einsum-dispatchStephan Hoyer2018-10-251-8/+195
|\
| * MAINT: provide an algorithm that blocks matrices with a single memory copy.Mark Harfouche2018-10-201-8/+195
| |
* | MAINT: add comment explaining _block_dispatcherStephan Hoyer2018-10-191-0/+3
| |
* | ENH: __array_function__ for np.einsum and np.blockStephan Hoyer2018-10-121-1/+10
|/
* Merge pull request #12115 from shoyer/array-function-numpy-coreCharles Harris2018-10-111-0/+39
|\ | | | | ENH: __array_function__ support for most of numpy.core
| * ENH: __array_function__ support for most of numpy.coreStephan Hoyer2018-10-081-0/+39
| | | | | | | | | | | | With the notable exceptions of np.einsum and np.block. xref GH12028
* | Merge pull request #11979 from hmaarrfk/block_single_array_copy_testMatti Picus2018-10-091-1/+8
|\ \ | |/ |/| MAINT: Ensure that a copy of the array is returned when calling `block`.
| * MAINT: Ensure that block returns a new arrayMark Harfouche2018-09-191-1/+8
| | | | | | | | | | | | | | | | In the case that a user calls np.block(array), the old block function would return a view into the array. This ensures that a new array is returned
* | MAINT: speed up _block by avoiding a recursive closureMark Harfouche2018-09-201-18/+15
|/
* MAINT: Show the location of an empty list in np.blockEric Wieser2018-09-181-10/+22
|
* DOC: Use a standard-style docstring to explain `_block_check_depths_match`Eric Wieser2018-09-171-9/+16
|
* MAINT: refactor design of recursive closures (#11910)Matti Picus2018-09-161-9/+5
|
* BUG: break cyclic refs in recursive closuresAllan Haldane2018-02-181-1/+7
| | | | Fixes #10620
* DOC: v/h/dstack docstr shouldn't imply deprecationAllan Haldane2017-11-211-24/+19
| | | | [ci skip]
* REV: Undo bad rebase in gh-8981 (7fdfdd6a52fc0761c0d45931247c5ed2480224eb)Eric Wieser2017-11-121-148/+88
| | | | This restores the changes in gh-9667 that were overwritten.
* ENH: print void repr/str using hex notationAllan Haldane2017-11-121-88/+148
|
* Rm unnecessary enumerateJamie Townsend2017-11-091-1/+1
|