summaryrefslogtreecommitdiff
path: root/numpy
Commit message (Collapse)AuthorAgeFilesLines
* ENH: add type stubs from numpy-stubsJosh Wilson2020-06-0634-0/+2489
| | | | | | | | | | | | | | | | | | | | | 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
* Merge pull request #15162 from seberg/reduce-axes-tryMatti Picus2020-06-0410-595/+479
|\ | | | | BUG,MAINT: Fix issues with non-reduce broadcasting axes
| * BUG: The reduction output must not cause the input to be broadcastSebastian Berg2020-05-302-1/+15
| | | | | | | | | | | | | | 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.
| * MAINT: Address review comments related to NPY_ITER_REDUCTION_AXISSebastian Berg2020-05-304-11/+11
| | | | | | | | Incorporate suggestions by Marten and Eric.
| * DOC: Slightly improve error message on incorrectly shaped reductionsSebastian Berg2020-05-111-7/+9
| |
| * BUG,MAINT: Simplify reduction result creation using reduce axisSebastian Berg2020-05-113-387/+160
| | | | | | | | | | | | | | | | | | | | | | 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.
| * BUG: Avoid incorrect broadcasts on non-core outputs in gufuncsSebastian Berg2020-05-112-6/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
| * MAINT: Use reduction axis marker for einsumSebastian Berg2020-05-111-4/+2
| |
| * ENH: Allow specifying reduction axis in nditer/NpyIterSebastian Berg2020-05-112-12/+92
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
| * MAINT: Simplify strides and axis check in npyiter_new_temp_arraySebastian Berg2020-05-112-64/+75
| | | | | | | | | | | | 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.
| * MAINT: Simplify signature of npyiter_replace_axisdataSebastian Berg2020-05-111-13/+11
| |
| * MAINT: (nditer) move duplicated reduce axis check into helper funcSebastian Berg2020-05-111-54/+43
| |
| * MAINT: Simplify undoing of iter-axis-perm in nditerSebastian Berg2020-05-113-54/+57
| |
* | Merge pull request #16468 from scivision/gcc10Sebastian Berg2020-06-041-1/+2
|\ \ | | | | | | BUG: fix GCC 10 major version comparison
| * | BUG: gcc >= 10: correctly compare major versionMichael Hirsch2020-06-021-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* | | Merge pull request #15666 from rossbar/enh/poly_strMatti Picus2020-06-044-23/+463
|\ \ \ | | | | | | | | ENH: Improved `__str__` for polynomials
| * | | STY: Move comment outside of try/except.Ross Barnowski2020-05-131-3/+3
| | | |
| * | | Handle TypeError in _generate_str for coefs.Ross Barnowski2020-05-132-7/+54
| | | | | | | | | | | | | | | | | | | | | | | | 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.
| * | | ENH: Improved __str__, __format__ for polynomialsRoss Barnowski2020-05-074-23/+416
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* | | | Merge pull request #16389 from seberg/hardcode-scalar-buffersMatti Picus2020-06-0411-30/+182
|\ \ \ \ | | | | | | | | | | ENH: Hardcode buffer handling for simple scalars
| * | | | ENH: Hardcode buffer handling for simple scalarsSebastian Berg2020-05-3111-30/+182
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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).
* | | | | MAINT: Chain some exceptions. (#16418)Zuhair Ali-Khan2020-06-044-12/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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>
* | | | | Merge pull request #16485 from seberg/gufunc-output-broadcasts-inputsMatti Picus2020-06-042-3/+22
|\ \ \ \ \ | | | | | | | | | | | | BUG: Fix result when a gufunc output broadcasts the inputs.
| * | | | | BUG: Fix result when a gufunc output broadcasts the inputs.Sebastian Berg2020-06-022-3/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* | | | | | Merge pull request #16474 from eric-wieser/tidy-piecewiseMatti Picus2020-06-021-8/+6
|\ \ \ \ \ \ | |_|_|_|/ / |/| | | | | MAINT: use zip instead of range in piecewise
| * | | | | MAINT: use zip instead of range in piecewiseEric Wieser2020-06-011-8/+6
| | | | | | | | | | | | | | | | | | | | | | | | Minor cleanup while looking at something else.
* | | | | | Merge pull request #16463 from sethtroisi/tst_filter_filteredSebastian Berg2020-06-011-3/+16
|\ \ \ \ \ \ | | | | | | | | | | | | | | DOC: Improve assert_warns docstring with example
| * | | | | | DOC: Improve assert_warns docstring with exampleSeth Troisi2020-06-011-3/+16
| | | | | | |
* | | | | | | ENH: ARM Neon implementation with intrinsic for np.argmax. (#16375)Chunlin2020-06-011-1/+25
| | | | | | | | | | | | | | | | | | | | | * Neon implementation with intrinsic for bool argmax
* | | | | | | ENH: Use AVX-512 for np.frexp and np.ldexp (#16371)Raghuveer Devulapalli2020-05-315-8/+255
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * TST: Adding tests to validate strided np.ldexp and np.frexp * ENH: Use AVX-512 for float and double np.ldexp
* | | | | | | DEP: Deprecate passing shape=None to mean shape=()Eric Wieser2020-05-314-14/+33
| |/ / / / / |/| | | | | | | | | | | | | | | | | 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 (#16334)Raghuveer Devulapalli2020-05-317-9/+168
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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
* | | | | | TST: Add tests for PyArray_IntpConverter (gh-16454)Eric Wieser2020-05-312-0/+48
| |/ / / / |/| | | | | | | | | Split from gh-15886.
* | | | | Merge pull request #16444 from rgommers/sinc-docCharles Harris2020-05-301-4/+11
|\ \ \ \ \ | | | | | | | | | | | | DOC: make clearer that sinc is normalized by a factor pi
| * | | | | DOC: make clearer that sinc is normalized by a factor piRalf Gommers2020-05-301-4/+11
| | | | | | | | | | | | | | | | | | | | | | | | Addresses gh-13457
* | | | | | investigate into warning usage, fixes deprecated warnforfun2020-05-301-2/+1
|/ / / / /
* | | | | MNT: Catch remaining cases of Py_SIZE and Py_TYPE as lvaluesThomas A Caswell2020-05-292-5/+4
| | | | |
* | | | | Merge pull request #16417 from tacaswell/fix_py310_compatCharles Harris2020-05-296-8/+17
|\ \ \ \ \ | | | | | | | | | | | | MAINT: support python 3.10
| * | | | | MNT: be more precise about version supportThomas A Caswell2020-05-291-5/+8
| | | | | | | | | | | | | | | | | | | | | | | | Co-authored-by: Eric Wieser <wieser.eric@gmail.com>
| * | | | | MNT: define macros supplied in py39 and aboveThomas A Caswell2020-05-291-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
| * | | | | MNT: support python 3.10Thomas A Caswell2020-05-295-8/+8
| |/ / / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* | | | | BUG: Add extern to PyArrayDTypeMeta_Type declarationSebastian Berg2020-05-291-1/+1
|/ / / / | | | | | | | | | | | | | | | | | | | | | | | | This was missing the extern, but pre GCC 10 it seemed to have worked fine without. Closes gh-16419
* | | | Merge pull request #16422 from sethtroisi/tst_filter_filteredRalf Gommers2020-05-291-5/+3
|\ \ \ \ | | | | | | | | | | DOC: Update assert_warns parameter list
| * | | | DOC: Update assert_warns parameter listSeth Troisi2020-05-281-5/+3
| | | | |
* | | | | TST: Simplify assert_warns in test_io.pySeth Troisi2020-05-281-17/+8
|/ / / /
* | | | Merge pull request #15900 from seberg/deprecate-empty-indexing-errorMatti Picus2020-05-282-9/+73
|\ \ \ \ | | | | | | | | | | DEP: Ensure indexing errors will be raised even on empty results
| * | | | DEP: Ensure indexing errors will be raised even on empty resultsSebastian Berg2020-05-272-9/+73
| |/ / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* | | | Merge pull request #16304 from seiko2plus/issue_16302Charles Harris2020-05-272-9/+34
|\ \ \ \ | | | | | | | | | | TST, MAINT: Fix detecting and testing armhf features
| * | | | TST, MAINT: Fix detecting and testing armhf featuresSayed Adel2020-05-262-9/+34
| | | | | | | | | | | | | | | | | | | | | | | | | - fix detect and test Arm Advanced SIMD on aarch32 - fix testing armhf's rootfs on aarch64 kernel
* | | | | Merge pull request #15508 from seberg/dtypemeta-newMatti Picus2020-05-2714-30/+481
|\ \ \ \ \ | | | | | | | | | | | | API: Create Preliminary DTypeMeta class and np.dtype subclasses