| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
| |
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.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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)
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
| |
The numbers chosen in the stacking examples can make them difficult to interpret. I suggest using different numbers to make it unambiguous.
|
|
|
| |
concatate to concatenate
|
| |
|
|
|
|
|
|
|
|
|
| |
This PR uses simple cases of PEP 380 to rewrite:
for v in g:
yield v
into:
yield from <expr>
|
| |
|
|
|
|
|
| |
As numpy is Python 3 only, these import statements are now unnecessary
and don't alter runtime behavior.
|
| |
|
| |
|
|
|
|
|
|
| |
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
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
|
| |
|
|
|
|
|
|
| |
* DOC, MAINT: Misc. typo fixes
Found via `codespell`
|
| |
|
| |
|
| |
|
| |
|
|
|
|
|
|
|
|
|
|
| |
- 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__``).
|
| |
|
| |
|
|
|
|
|
|
|
|
| |
* 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
|
| |
|
| |
|
| |
|
| |
|
|
|
|
|
|
| |
Fixes gh-12263
We can't support generators with dispatch for ``__array_function__``.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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'):
...
|
|\ |
|
| | |
|
| | |
|
|/ |
|
|\
| |
| | |
ENH: __array_function__ support for most of numpy.core
|
| |
| |
| |
| |
| |
| | |
With the notable exceptions of np.einsum and np.block.
xref GH12028
|
|\ \
| |/
|/| |
MAINT: Ensure that a copy of the array is returned when calling `block`.
|
| |
| |
| |
| |
| |
| |
| |
| | |
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
|
|/ |
|
| |
|
| |
|
| |
|
|
|
|
| |
Fixes #10620
|
|
|
|
| |
[ci skip]
|
|
|
|
| |
This restores the changes in gh-9667 that were overwritten.
|
| |
|
| |
|