| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Add the type stubs and tests from numpy-stubs. Things this entails:
- Copy over the stubs (numpy/__init__.pyi and
numpy/core/_internal.pyi)
- The only modification made was removing `ndarray.tostring` since
it is deprecated
- Update some setup.py files to include pyi files
- Move the tests from numpy-stubs/tests into numpy/tests
- Skip them if mypy is not installed (planning on setting up CI in a
future PR)
- Add a mypy.ini; use it to configure mypy in the tests
- It tells mypy where to find NumPy in the test env
- It ignores internal NumPy type errors (since we only want to
consider errors from the tests cases)
- Some small edits were made to fix test cases that were emitting
deprecation warnings
- Add numpy/py.typed so that the types are picked up in an
installed version of NumPy
|
|\
| |
| | |
BUG,MAINT: Fix issues with non-reduce broadcasting axes
|
| |
| |
| |
| |
| |
| |
| | |
This was previously checked for, but during the refactor using
NPY_ITER_REDUCTION_AXIS to allocate the result in the iterator
instead of manually was lost here.
Einsum has a similar issue, but this is not modified here.
|
| |
| |
| |
| | |
Incorporate suggestions by Marten and Eric.
|
| | |
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
The new reduce axis marker for nditer/NpyIter allows to move the
allocation logic necessary to allocate the reduction result
to the nditer, thus simplifying the logic here.
This leads to some other related cleanups of the result
initialization.
The subok flag was removed, since it was always set to 0
and the iterator rejects subclasses.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Mark the core dimensions as reduce axis. This allows them to be
freely broadcast (basically ignored for most practical purposes)
while other axes are normally broadcast even though the operand is
read-only or write-only.
If we were to use read-write operands with `REDUCE_OK` these
additional dimensions are currently simply absored as reduction
dimensions...
(I hope this is understandable, please see the issues/test
for an example...)
Fixes gh-15139, replaces gh-15142
Co-Authored-By: Marten van Kerkwijk <mhvk@astro.utoronto.ca>
|
| | |
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
A reduction axis can be a broadcast axis (-1), which does not
exist. Or an existing axis which then must have a length of 1, or
will be allocated with a length of 1.
This allows the correct allocation of reduction outputs with
axes of size 1 (instead of only newaxis/-1), i.e. it allows
supporting the result output with `keepdims=True` in reductions.
It can also be used by generalized ufuncs to specific that one
operand does not need to iterate a core dimensions. In the case
of generalized ufuncs, this is handled like a reduce dimensions,
but that dimension is later removed. This means that the operand
can be specified without read-write.
It mainly is necessary to allow normal broadcasting for the axes
_not_ marked as reduce axis.
In most cases however, an operand should never use broadcasting
when marking axes as reduction.
|
| |
| |
| |
| |
| |
| | |
The stride calculation and axis check redid some of the work
finding the number of dimensions again. This simplifies the logic
and clarifies an error message a bit.
|
| | |
|
| | |
|
| | |
|
|\ \
| | |
| | | |
BUG: fix GCC 10 major version comparison
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
The comparison of GCC major version used a string
comparison, which is known to break when comparing
single vs. double version numbers. This fix
compares the integer of the major GCC version.
Before this fix, GCC/Gfortran 10 would get inappropriate
flag "-mno-cygwin" applied, which was removed in GCC 4
and makes GCC error out.
|
|\ \ \
| | | |
| | | | |
ENH: Improved `__str__` for polynomials
|
| | | | |
|
| | | |
| | | |
| | | |
| | | |
| | | |
| | | | |
Add a fallback for TypeErrors that are raised when attempting
to compare arbitrary elements (e.g. strings or Python complex)
to 0 in _generate_str.
|
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | | |
Changes the printing style of instances of the convenience classes in
the polynomial package to a more "human-readable" format.
__str__ has been modified and __format__ added to ABCPolyBase, modifying
the string representation of polynomial instances, e.g. when printed.
__repr__ and the _repr_latex method (which is used in the Jupyter
environment are unchanged.
Two print formats have been added: 'unicode' and 'ascii'. 'unicode' is
the default mode on *nix systems, and uses unicode values for numeric
subscripts and superscripts in the polynomial expression. The 'ascii'
format is the default on Windows (due to font considerations) and uses
Python-style syntax to represent powers, e.g. x**2. The default
printing style can be controlled at the package-level with the
set_default_printstyle function.
The ABCPolyBase.__str__ has also been made to respect the linewidth
printoption. Other parameters from the printoptions dictionary are not
used.
Co-Authored-By: Warren Weckesser <warren.weckesser@gmail.com>
Co-authored-by: Eric Wieser <wieser.eric@gmail.com>
|
|\ \ \ \
| | | | |
| | | | | |
ENH: Hardcode buffer handling for simple scalars
|
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | | |
For most scalars (except void ones) exposing the buffer interface
is trivial and does not require any fancy "format" handling.
Except for unicode, their buffer interface is also static and thus
can simply be hardcoded.
The main advantage, is that currently the buffer interface uses
a global dictionary to store these buffers and thus requires
probing that dictionary for every single scalar dealloc. This
results in an overhead of about 30% for simple operations (such
as slicing and simple math).
|
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | | |
* ENH: Chain extensions in numpy and numpy/core
Co-authored-by: Ross Barnowski <rossbar@berkeley.edu>
Co-authored-by: Zuhair Ali-Khan <54608785+zalikh2@users.noreply.github.com>
|
|\ \ \ \ \
| | | | | |
| | | | | | |
BUG: Fix result when a gufunc output broadcasts the inputs.
|
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | | |
In this case no error was given, but additional dimensions in the
output simply ignored. Thus the returned array was only partially
set.
Now it will be fully set, with the calculation being repeated as
often as necessary (typical broadcasting logic). This is consistent
with how normal ufuncs work.
Closes gh-16484
|
|\ \ \ \ \ \
| |_|_|_|/ /
|/| | | | | |
MAINT: use zip instead of range in piecewise
|
| | | | | |
| | | | | |
| | | | | |
| | | | | | |
Minor cleanup while looking at something else.
|
|\ \ \ \ \ \
| | | | | | |
| | | | | | | |
DOC: Improve assert_warns docstring with example
|
| | | | | | | |
|
| | | | | | |
| | | | | | |
| | | | | | | |
* Neon implementation with intrinsic for bool argmax
|
| | | | | | |
| | | | | | |
| | | | | | |
| | | | | | |
| | | | | | | |
* TST: Adding tests to validate strided np.ldexp and np.frexp
* ENH: Use AVX-512 for float and double np.ldexp
|
| |/ / / / /
|/| | | | |
| | | | | |
| | | | | | |
This requires some minor tweaks in `np.random` because there the two have different meanings, with `()` meaning 0d array and `None` meaning scalar.
|
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | | |
* ENH: Use AVX-512 for np.isnan, np.infinite, np.isinf and np.signbit
* TST: Add tests to validate isnan, isfinite, signbit and isinf ufuncs
* BENCH: Adding benchmarks for isnan, isinf, isfinite and signbit
|
| |/ / / /
|/| | | |
| | | | | |
Split from gh-15886.
|
|\ \ \ \ \
| | | | | |
| | | | | | |
DOC: make clearer that sinc is normalized by a factor pi
|
| | | | | |
| | | | | |
| | | | | |
| | | | | | |
Addresses gh-13457
|
|/ / / / / |
|
| | | | | |
|
|\ \ \ \ \
| | | | | |
| | | | | | |
MAINT: support python 3.10
|
| | | | | |
| | | | | |
| | | | | |
| | | | | | |
Co-authored-by: Eric Wieser <wieser.eric@gmail.com>
|
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | | |
To support the change to Py_SIZE and Py_TYPE the Py_SET_SIZE and
Py_SET_TYPE macros are provided in py39. This provides the same
macros falling back to the old method for < py39.
|
| |/ / / /
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | | |
In https://github.com/python/cpython/pull/20290 CPython changed
`Py_TYPE` from a macro to an inline function. This requires a code
change to us `Py_SET_TYPE` instead when using `Py_TYPE()` as a lvalue
in c code.
In https://github.com/python/cpython/pull/20429 CPython changed
`Py_SIZE` from a macro to an inline function. This requires a code
change to us `Py_SET_SIZE` instead of using `Py_SIZE` as a lvalue in c
code.
|
|/ / / /
| | | |
| | | |
| | | |
| | | |
| | | |
| | | | |
This was missing the extern, but pre GCC 10 it seemed to have worked
fine without.
Closes gh-16419
|
|\ \ \ \
| | | | |
| | | | | |
DOC: Update assert_warns parameter list
|
| | | | | |
|
|/ / / / |
|
|\ \ \ \
| | | | |
| | | | | |
DEP: Ensure indexing errors will be raised even on empty results
|
| |/ / /
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | | |
Previously, when the indexing result was empty, no check was done
for backward compatibility with pre 1.9 (assumingly).
This may have been only necessary when the outer iteration is empty
as opposed to when just the inner iteration is empty, though.
In any case, it is arguably buggy to ignore indexing errors in this
case. Since there may have been a reason back in the day, and this
is probably extremely rare, optiming for a brief deprecation period
for now.
Closes gh-15898
Co-authored-by: Eric Wieser <wieser.eric@gmail.com>
Co-authored-by: Matti Picus <matti.picus@gmail.com>
|
|\ \ \ \
| | | | |
| | | | | |
TST, MAINT: Fix detecting and testing armhf features
|
| | | | |
| | | | |
| | | | |
| | | | |
| | | | | |
- fix detect and test Arm Advanced SIMD on aarch32
- fix testing armhf's rootfs on aarch64 kernel
|
|\ \ \ \ \
| | | | | |
| | | | | | |
API: Create Preliminary DTypeMeta class and np.dtype subclasses
|