From e86846ef26ce76052e02c3fda8e116b4275c050f Mon Sep 17 00:00:00 2001 From: Charles Harris Date: Sat, 27 Mar 2021 16:09:00 -0600 Subject: [PATCH 01/33] REL: prepare 1.20.x for further development --- doc/source/release.rst | 1 + doc/source/release/1.20.3-notes.rst | 9 +++++++++ pavement.py | 2 +- setup.py | 4 ++-- 4 files changed, 13 insertions(+), 3 deletions(-) create mode 100644 doc/source/release/1.20.3-notes.rst diff --git a/doc/source/release.rst b/doc/source/release.rst index 1edd693b9e0b..35f6f59b9beb 100644 --- a/doc/source/release.rst +++ b/doc/source/release.rst @@ -5,6 +5,7 @@ Release Notes .. toctree:: :maxdepth: 3 + 1.20.3 1.20.2 1.20.1 1.20.0 diff --git a/doc/source/release/1.20.3-notes.rst b/doc/source/release/1.20.3-notes.rst new file mode 100644 index 000000000000..5b3c200b684b --- /dev/null +++ b/doc/source/release/1.20.3-notes.rst @@ -0,0 +1,9 @@ +.. currentmodule:: numpy + +========================== +NumPy 1.20.3 Release Notes +========================== + +NumPy 1,20.3 is a bugfix release containing several fixes merged to the main +branch after the NumPy 1.20.2 release. + diff --git a/pavement.py b/pavement.py index a5c021f513b8..e8544a0ddf59 100644 --- a/pavement.py +++ b/pavement.py @@ -37,7 +37,7 @@ #----------------------------------- # Path to the release notes -RELEASE_NOTES = 'doc/source/release/1.20.2-notes.rst' +RELEASE_NOTES = 'doc/source/release/1.20.3-notes.rst' #------------------------------------------------------- diff --git a/setup.py b/setup.py index 1206bcc6a995..65cbd87197f9 100755 --- a/setup.py +++ b/setup.py @@ -56,8 +56,8 @@ MAJOR = 1 MINOR = 20 -MICRO = 2 -ISRELEASED = True +MICRO = 3 +ISRELEASED = False VERSION = '%d.%d.%d' % (MAJOR, MINOR, MICRO) # The first version not in the `Programming Language :: Python :: ...` classifiers above From 03c6734641214134d116fb92094f4bee651ece15 Mon Sep 17 00:00:00 2001 From: Bas van Beek Date: Tue, 13 Apr 2021 12:51:13 +0200 Subject: [PATCH 02/33] BUG: Correct `datetime64` missing type overload for `datetime.date` --- numpy/__init__.pyi | 12 +++++++++++- numpy/typing/tests/data/pass/scalars.py | 1 + 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/numpy/__init__.pyi b/numpy/__init__.pyi index d275ad27a45e..dc9e92093872 100644 --- a/numpy/__init__.pyi +++ b/numpy/__init__.pyi @@ -1758,11 +1758,21 @@ class object_(generic): @property def imag(self: _ArraySelf) -> _ArraySelf: ... +# The `datetime64` constructors requires an object with the three attributes below, +# and thus supports datetime duck typing +class _DatetimeScalar(Protocol): + @property + def day(self) -> int: ... + @property + def month(self) -> int: ... + @property + def year(self) -> int: ... + class datetime64(generic): @overload def __init__( self, - __value: Union[None, datetime64, _CharLike, dt.datetime] = ..., + __value: Union[None, datetime64, _CharLike, _DatetimeScalar] = ..., __format: Union[_CharLike, Tuple[_CharLike, _IntLike]] = ..., ) -> None: ... @overload diff --git a/numpy/typing/tests/data/pass/scalars.py b/numpy/typing/tests/data/pass/scalars.py index b7f7880e4561..6c6b2c0c1ad9 100644 --- a/numpy/typing/tests/data/pass/scalars.py +++ b/numpy/typing/tests/data/pass/scalars.py @@ -85,6 +85,7 @@ def __float__(self) -> float: np.datetime64(np.datetime64()) np.datetime64(dt.datetime(2000, 5, 3)) np.datetime64(None) +np.datetime64(dt.date(2000, 5, 3)) np.datetime64(None, "D") np.timedelta64() From 31938d02312516d215694a045cc55ed1ba40206f Mon Sep 17 00:00:00 2001 From: Bas van Beek Date: Mon, 25 Jan 2021 16:03:54 +0100 Subject: [PATCH 03/33] MAINT: Remove `__all__` in favor of explicit reexports --- numpy/__init__.pyi | 156 ++++++++++++++++----------------------------- 1 file changed, 55 insertions(+), 101 deletions(-) diff --git a/numpy/__init__.pyi b/numpy/__init__.pyi index d275ad27a45e..0d7d041835ae 100644 --- a/numpy/__init__.pyi +++ b/numpy/__init__.pyi @@ -84,66 +84,66 @@ else: # Ensures that the stubs are picked up from numpy import ( - char, - ctypeslib, - emath, - fft, - lib, - linalg, - ma, - matrixlib, - polynomial, - random, - rec, - testing, - version, + char as char, + ctypeslib as ctypeslib, + emath as emath, + fft as fft, + lib as lib, + linalg as linalg, + ma as ma, + matrixlib as matrixlib, + polynomial as polynomial, + random as random, + rec as rec, + testing as testing, + version as version, ) from numpy.core.function_base import ( - linspace, - logspace, - geomspace, + linspace as linspace, + logspace as logspace, + geomspace as geomspace, ) from numpy.core.fromnumeric import ( - take, - reshape, - choose, - repeat, - put, - swapaxes, - transpose, - partition, - argpartition, - sort, - argsort, - argmax, - argmin, - searchsorted, - resize, - squeeze, - diagonal, - trace, - ravel, - nonzero, - shape, - compress, - clip, - sum, - all, - any, - cumsum, - ptp, - amax, - amin, - prod, - cumprod, - ndim, - size, - around, - mean, - std, - var, + take as take, + reshape as reshape, + choose as choose, + repeat as repeat, + put as put, + swapaxes as swapaxes, + transpose as transpose, + partition as partition, + argpartition as argpartition, + sort as sort, + argsort as argsort, + argmax as argmax, + argmin as argmin, + searchsorted as searchsorted, + resize as resize, + squeeze as squeeze, + diagonal as diagonal, + trace as trace, + ravel as ravel, + nonzero as nonzero, + shape as shape, + compress as compress, + clip as clip, + sum as sum, + all as all, + any as any, + cumsum as cumsum, + ptp as ptp, + amax as amax, + amin as amin, + prod as prod, + cumprod as cumprod, + ndim as ndim, + size as size, + around as around, + mean as mean, + std as std, + var as var, ) from numpy.core._asarray import ( @@ -224,53 +224,7 @@ from numpy.core.shape_base import ( vstack as vstack, ) -# Add an object to `__all__` if their stubs are defined in an external file; -# their stubs will not be recognized otherwise. -# NOTE: This is redundant for objects defined within this file. -__all__ = [ - "linspace", - "logspace", - "geomspace", - "take", - "reshape", - "choose", - "repeat", - "put", - "swapaxes", - "transpose", - "partition", - "argpartition", - "sort", - "argsort", - "argmax", - "argmin", - "searchsorted", - "resize", - "squeeze", - "diagonal", - "trace", - "ravel", - "nonzero", - "shape", - "compress", - "clip", - "sum", - "all", - "any", - "cumsum", - "ptp", - "amax", - "amin", - "prod", - "cumprod", - "ndim", - "size", - "around", - "mean", - "std", - "var", -] - +__all__: List[str] __path__: List[str] __version__: str From 09be5ac6aad7d2fffb17fde200a22bf3a1cd4bed Mon Sep 17 00:00:00 2001 From: Kamil Choudhury Date: Tue, 30 Mar 2021 17:22:42 +0000 Subject: [PATCH 04/33] Strip extra newline when dumping gfortran version on MacOS --- numpy/distutils/fcompiler/gnu.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/numpy/distutils/fcompiler/gnu.py b/numpy/distutils/fcompiler/gnu.py index 68d1501eee6a..eac4cbb4779b 100644 --- a/numpy/distutils/fcompiler/gnu.py +++ b/numpy/distutils/fcompiler/gnu.py @@ -32,7 +32,8 @@ def gnu_version_match(self, version_string): """Handle the different versions of GNU fortran compilers""" # Strip warning(s) that may be emitted by gfortran while version_string.startswith('gfortran: warning'): - version_string = version_string[version_string.find('\n') + 1:] + version_string =\ + version_string[version_string.find('\n') + 1:].strip() # Gfortran versions from after 2010 will output a simple string # (usually "x.y", "x.y.z" or "x.y.z-q") for ``-dumpversion``; older From 3fc7eb085baee307f34db74d138e736ac1bcccad Mon Sep 17 00:00:00 2001 From: Anne Archibald Date: Sun, 28 Mar 2021 13:36:25 +0100 Subject: [PATCH 05/33] BUG: fix segfault in object/longdouble operations The operation None*np.longdouble(3) was causing infinite recursion as it searched for the appropriate conversion method. This resolves that, both for general operations and for remainders specifically (they fail in a subtly different way). Closes #18548 --- numpy/core/src/umath/scalarmath.c.src | 61 +++++++++++++++++++- numpy/core/tests/test_scalarmath.py | 81 +++++++++++++++++++++++++++ 2 files changed, 141 insertions(+), 1 deletion(-) diff --git a/numpy/core/src/umath/scalarmath.c.src b/numpy/core/src/umath/scalarmath.c.src index 86dade0f180c..32ddb58a2e59 100644 --- a/numpy/core/src/umath/scalarmath.c.src +++ b/numpy/core/src/umath/scalarmath.c.src @@ -737,6 +737,9 @@ _@name@_convert2_to_ctypes(PyObject *a, @type@ *arg1, { int ret; ret = _@name@_convert_to_ctype(a, arg1); + if (ret == -2) { + ret = -3; + } if (ret < 0) { return ret; } @@ -1029,7 +1032,7 @@ static PyObject * /**begin repeat * - * #name = cfloat, cdouble, clongdouble# + * #name = cfloat, cdouble# * */ @@ -1045,6 +1048,62 @@ static PyObject * /**end repeat**/ +/**begin repeat + * + * #oper = divmod, remainder# + * + */ + +/* +Complex numbers do not support remainder operations. Unfortunately, +the type inference for long doubles is complicated, and if a remainder +operation is not defined - if the relevant field is left NULL - then +operations between long doubles and objects lead to an infinite recursion +instead of a TypeError. This should ensure that once everything gets +converted to complex long doubles you correctly get a reasonably +informative TypeError. This fixes the last part of bug gh-18548. +*/ + +static PyObject * +clongdouble_@oper@(PyObject *a, PyObject *b) +{ + PyObject *ret; + npy_clongdouble arg1, arg2; + npy_clongdouble out; + + BINOP_GIVE_UP_IF_NEEDED(a, b, nb_@oper@, clongdouble_@oper@); + + switch(_clongdouble_convert2_to_ctypes(a, &arg1, b, &arg2)) { + case 0: + break; + case -1: + /* one of them can't be cast safely must be mixed-types*/ + return PyArray_Type.tp_as_number->nb_@oper@(a,b); + case -2: + /* use default handling */ + if (PyErr_Occurred()) { + return NULL; + } + return PyGenericArrType_Type.tp_as_number->nb_@oper@(a,b); + case -3: + /* + * special case for longdouble and clongdouble + * because they have a recursive getitem in their dtype + */ + Py_INCREF(Py_NotImplemented); + return Py_NotImplemented; + } + + /* + * here we do the actual calculation with arg1 and arg2 + * as a function call. + */ + PyErr_SetString(PyExc_TypeError, "complex long doubles do not support remainder"); + return NULL; +} + +/**end repeat**/ + /**begin repeat * * #name = half, float, double, longdouble, cfloat, cdouble, clongdouble# diff --git a/numpy/core/tests/test_scalarmath.py b/numpy/core/tests/test_scalarmath.py index d8529418e58b..e62a0f021374 100644 --- a/numpy/core/tests/test_scalarmath.py +++ b/numpy/core/tests/test_scalarmath.py @@ -1,9 +1,12 @@ +import contextlib import sys import warnings import itertools import operator import platform import pytest +from hypothesis import given, settings, Verbosity, assume +from hypothesis.strategies import sampled_from import numpy as np from numpy.testing import ( @@ -707,3 +710,81 @@ def test_shift_all_bits(self, type_code, op): shift_arr = np.array([shift]*32, dtype=dt) res_arr = op(val_arr, shift_arr) assert_equal(res_arr, res_scl) + + +@contextlib.contextmanager +def recursionlimit(n): + o = sys.getrecursionlimit() + try: + sys.setrecursionlimit(n) + yield + finally: + sys.setrecursionlimit(o) + + +objecty_things = [object(), None] +reasonable_operators_for_scalars = [ + operator.lt, operator.le, operator.eq, operator.ne, operator.ge, + operator.gt, operator.add, operator.floordiv, operator.mod, + operator.mul, operator.matmul, operator.pow, operator.sub, + operator.truediv, +] + + +@given(sampled_from(objecty_things), + sampled_from(reasonable_operators_for_scalars), + sampled_from(types)) +@settings(verbosity=Verbosity.verbose) +def test_operator_object_left(o, op, type_): + try: + with recursionlimit(100): + op(o, type_(1)) + except TypeError: + pass + + +@given(sampled_from(objecty_things), + sampled_from(reasonable_operators_for_scalars), + sampled_from(types)) +def test_operator_object_right(o, op, type_): + try: + with recursionlimit(100): + op(type_(1), o) + except TypeError: + pass + + +@given(sampled_from(reasonable_operators_for_scalars), + sampled_from(types), + sampled_from(types)) +def test_operator_scalars(op, type1, type2): + try: + op(type1(1), type2(1)) + except TypeError: + pass + + +@pytest.mark.parametrize("op", reasonable_operators_for_scalars) +def test_longdouble_inf_loop(op): + try: + op(np.longdouble(3), None) + except TypeError: + pass + try: + op(None, np.longdouble(3)) + except TypeError: + pass + + +@pytest.mark.parametrize("op", reasonable_operators_for_scalars) +def test_clongdouble_inf_loop(op): + if op in {operator.mod} and False: + pytest.xfail("The modulo operator is known to be broken") + try: + op(np.clongdouble(3), None) + except TypeError: + pass + try: + op(None, np.longdouble(3)) + except TypeError: + pass From 04b657d4da5b5f74f7356f3def7dab6ded7cd2c1 Mon Sep 17 00:00:00 2001 From: Anne Archibald Date: Sun, 28 Mar 2021 16:22:17 +0100 Subject: [PATCH 06/33] Remove unused variables --- numpy/core/src/umath/scalarmath.c.src | 2 -- 1 file changed, 2 deletions(-) diff --git a/numpy/core/src/umath/scalarmath.c.src b/numpy/core/src/umath/scalarmath.c.src index 32ddb58a2e59..66f97a831431 100644 --- a/numpy/core/src/umath/scalarmath.c.src +++ b/numpy/core/src/umath/scalarmath.c.src @@ -1067,9 +1067,7 @@ informative TypeError. This fixes the last part of bug gh-18548. static PyObject * clongdouble_@oper@(PyObject *a, PyObject *b) { - PyObject *ret; npy_clongdouble arg1, arg2; - npy_clongdouble out; BINOP_GIVE_UP_IF_NEEDED(a, b, nb_@oper@, clongdouble_@oper@); From afc158d6d9fcacabfbc533bfd46163fefbf85ec9 Mon Sep 17 00:00:00 2001 From: Sebastian Berg Date: Fri, 16 Apr 2021 12:52:55 -0500 Subject: [PATCH 07/33] CI: Use `towncrier build` explicitly Without any argument towncrier defaults to `build`. But towncrier added a `--version` argument to just print the towncrier version. NumPy relies on passing `--version` which collides. Even if towncrier might revert the change, using `towncrier build` explicitly just doesn't hurt. Closes gh-18788 --- .circleci/config.yml | 2 +- doc/release/upcoming_changes/README.rst | 2 +- tools/ci/test_all_newsfragments_used.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index ea50ca84fa52..baf779244a07 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -42,7 +42,7 @@ jobs: . venv/bin/activate pip install git+https://github.com/hawkowl/towncrier.git@master VERSION=$(python -c "import setup; print(setup.VERSION)") - towncrier --version $VERSION --yes + towncrier build --version $VERSION --yes ./tools/ci/test_all_newsfragments_used.py - run: diff --git a/doc/release/upcoming_changes/README.rst b/doc/release/upcoming_changes/README.rst index ff5ca514c3b2..436535ecddbc 100644 --- a/doc/release/upcoming_changes/README.rst +++ b/doc/release/upcoming_changes/README.rst @@ -50,7 +50,7 @@ and double-backticks for code. If you are unsure what pull request type to use, don't hesitate to ask in your PR. -You can install ``towncrier`` and run ``towncrier --draft --version 1.18`` +You can install ``towncrier`` and run ``towncrier build --draft --version 1.18`` if you want to get a preview of how your change will look in the final release notes. diff --git a/tools/ci/test_all_newsfragments_used.py b/tools/ci/test_all_newsfragments_used.py index c2e03154945d..62c9a05f95da 100755 --- a/tools/ci/test_all_newsfragments_used.py +++ b/tools/ci/test_all_newsfragments_used.py @@ -12,5 +12,5 @@ if fragments: print("The following files were not found by towncrier:") - print(" " + " \n".join(fragments)) + print(" " + "\n ".join(fragments)) sys.exit(1) From af8099f6972f0551ac85451be7e8be27b179a881 Mon Sep 17 00:00:00 2001 From: Charles Harris Date: Fri, 16 Apr 2021 15:49:54 -0600 Subject: [PATCH 08/33] MAINT: Use recent towncrier releases on PyPI. We were installing towncrier from the github master branch because there had been no releases with the needed fixes. That has changed with the recent release of versions 19.9.0 and 21.3.0. --- .circleci/config.yml | 8 ++++---- doc/HOWTO_RELEASE.rst.txt | 21 +++++++++++++++------ release_requirements.txt | 2 +- 3 files changed, 20 insertions(+), 11 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index baf779244a07..ac85d49373ff 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -91,7 +91,7 @@ jobs: - run: name: deploy devdocs command: | - if [ "${CIRCLE_BRANCH}" == "master" ]; then + if [ "${CIRCLE_BRANCH}" == "main" ]; then touch doc/build/html/.nojekyll ./tools/ci/push_docs_to_repo.py doc/build/html \ @@ -101,7 +101,7 @@ jobs: --message "Docs build of $CIRCLE_SHA1" \ --force else - echo "Not on the master branch; skipping deployment" + echo "Not on the main branch; skipping deployment" fi - add_ssh_keys: @@ -120,7 +120,7 @@ jobs: - run: name: deploy neps command: | - if [ "${CIRCLE_BRANCH}" == "master" ]; then + if [ "${CIRCLE_BRANCH}" == "main" ]; then touch doc/neps/_build/html/.nojekyll ./tools/ci/push_docs_to_repo.py doc/neps/_build/html \ @@ -130,5 +130,5 @@ jobs: --message "Docs build of $CIRCLE_SHA1" \ --force else - echo "Not on the master branch; skipping deployment" + echo "Not on the main branch; skipping deployment" fi diff --git a/doc/HOWTO_RELEASE.rst.txt b/doc/HOWTO_RELEASE.rst.txt index 5a9c4d5052b4..c64a36691705 100644 --- a/doc/HOWTO_RELEASE.rst.txt +++ b/doc/HOWTO_RELEASE.rst.txt @@ -18,7 +18,7 @@ Source tree NumPy Docs ---------- -- https://github.com/numpy/numpy/blob/master/doc/HOWTO_RELEASE.rst.txt +- https://github.com/numpy/numpy/blob/main/doc/HOWTO_RELEASE.rst.txt SciPy.org wiki @@ -35,7 +35,7 @@ Supported platforms and versions ================================ :ref:`NEP 29 ` outlines which Python versions are supported; For the first half of 2020, this will be Python >= 3.6. We test -NumPy against all these versions every time we merge code to master. Binary +NumPy against all these versions every time we merge code to main. Binary installers may be available for a subset of these versions (see below). OS X @@ -185,7 +185,7 @@ A typical release schedule is one beta, two release candidates and a final release. It's best to discuss the timing on the mailing list first, in order for people to get their commits in on time, get doc wiki edits merged, etc. After a date is set, create a new maintenance/x.y.z branch, add new empty -release notes for the next version in the master branch and update the Trac +release notes for the next version in the main branch and update the Trac Milestones. @@ -336,8 +336,8 @@ to public keyservers, with a command such as:: gpg --send-keys -Update the version of the master branch ---------------------------------------- +Update the version of the main branch +------------------------------------- Increment the release number in setup.py. Release candidates should have "rc1" (or "rc2", "rcN") appended to the X.Y.Z format. @@ -460,6 +460,15 @@ The scipy.org should be a PR at https://github.com/scipy/scipy.org. The file that needs modification is ``www/index.rst``. Search for ``News``. +Update oldest-supported-numpy +----------------------------- +If this release is the first one to support a new Python version, or the first +to provide wheels for a new platform or PyPy version, the version pinnings +in https://github.com/scipy/oldest-supported-numpy should be updated. +Either submit a PR with changes to ``setup.cfg`` there, or open an issue with +info on needed changes. + + Announce to the lists --------------------- The release should be announced on the mailing lists of @@ -483,5 +492,5 @@ After the final release is announced, a few administrative tasks are left to be done: - Forward port changes in the release branch to release notes and release - scripts, if any, to master branch. + scripts, if any, to main branch. - Update the Milestones in Trac. diff --git a/release_requirements.txt b/release_requirements.txt index c24e39c7849d..805ce9a8afe1 100644 --- a/release_requirements.txt +++ b/release_requirements.txt @@ -14,4 +14,4 @@ twine # building and notes Paver -towncrier +git+https://github.com/hawkowl/towncrier.git@master From befda74ef63a8da6d1dd0b9cccfbe7affbc8e182 Mon Sep 17 00:00:00 2001 From: Bas van Beek Date: Wed, 14 Apr 2021 23:09:28 +0200 Subject: [PATCH 09/33] MAINT: Ensure that the `np.ndarray` constructor can take any shape-like oject --- numpy/__init__.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/numpy/__init__.pyi b/numpy/__init__.pyi index 186ae5d30c4b..cd6f447d6dcf 100644 --- a/numpy/__init__.pyi +++ b/numpy/__init__.pyi @@ -1438,7 +1438,7 @@ class ndarray(_ArrayOrScalarCommon, Iterable, Sized, Container): def imag(self, value: ArrayLike) -> None: ... def __new__( cls: Type[_ArraySelf], - shape: Sequence[int], + shape: _ShapeLike, dtype: DTypeLike = ..., buffer: _BufferType = ..., offset: int = ..., From 19f0c6273ee28c67b32dd4b4cfecaf13ff6a3ff4 Mon Sep 17 00:00:00 2001 From: Bas van Beek Date: Wed, 14 Apr 2021 23:11:09 +0200 Subject: [PATCH 10/33] MAINT: Relax the integer-type-constraint of `npt._ShapeLike` Change `int` into the more forgiving `SupportsIndex` protocol --- numpy/typing/_shape.py | 11 ++++++++++- numpy/typing/tests/data/pass/array_constructors.py | 3 +++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/numpy/typing/_shape.py b/numpy/typing/_shape.py index 4629046ea3eb..b720c3ffc192 100644 --- a/numpy/typing/_shape.py +++ b/numpy/typing/_shape.py @@ -1,6 +1,15 @@ +import sys from typing import Sequence, Tuple, Union +if sys.version_info >= (3, 8): + from typing import SupportsIndex +else: + try: + from typing_extensions import SupportsIndex + except ImportError: + SupportsIndex = NotImplemented + _Shape = Tuple[int, ...] # Anything that can be coerced to a shape tuple -_ShapeLike = Union[int, Sequence[int]] +_ShapeLike = Union[SupportsIndex, Sequence[SupportsIndex]] diff --git a/numpy/typing/tests/data/pass/array_constructors.py b/numpy/typing/tests/data/pass/array_constructors.py index 63208f139c39..722fa4b7e3f6 100644 --- a/numpy/typing/tests/data/pass/array_constructors.py +++ b/numpy/typing/tests/data/pass/array_constructors.py @@ -17,6 +17,9 @@ class SubClass(np.ndarray): ... def func(i: int, j: int, **kwargs: Any) -> SubClass: return B +np.ndarray(Index()) +np.ndarray([Index()]) + np.array(1, dtype=float) np.array(1, copy=False) np.array(1, order='F') From 3e6ee82c01bd2a5ef5b6ad3c9401aae4290ae93b Mon Sep 17 00:00:00 2001 From: Bas van Beek Date: Thu, 15 Apr 2021 00:29:00 +0200 Subject: [PATCH 11/33] STY: pep8 fixes --- numpy/typing/tests/data/pass/array_constructors.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/numpy/typing/tests/data/pass/array_constructors.py b/numpy/typing/tests/data/pass/array_constructors.py index 722fa4b7e3f6..13159f6bbd14 100644 --- a/numpy/typing/tests/data/pass/array_constructors.py +++ b/numpy/typing/tests/data/pass/array_constructors.py @@ -1,11 +1,19 @@ from typing import List, Any import numpy as np + class Index: def __index__(self) -> int: return 0 -class SubClass(np.ndarray): ... + +class SubClass(np.ndarray): + pass + + +def func(i: int, j: int, **kwargs: Any) -> SubClass: + return B + i8 = np.int64(1) @@ -14,9 +22,6 @@ class SubClass(np.ndarray): ... B_stack = np.array([[1], [1]]).view(SubClass) C = [1] -def func(i: int, j: int, **kwargs: Any) -> SubClass: - return B - np.ndarray(Index()) np.ndarray([Index()]) From 3b4168828f798ab403eab0fa9e50ab7fda2528de Mon Sep 17 00:00:00 2001 From: Bas van Beek Date: Thu, 15 Apr 2021 02:07:47 +0200 Subject: [PATCH 12/33] TST: Fix a test failure for python 3.7 --- numpy/typing/tests/data/pass/array_constructors.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/numpy/typing/tests/data/pass/array_constructors.py b/numpy/typing/tests/data/pass/array_constructors.py index 13159f6bbd14..206f70a15bb1 100644 --- a/numpy/typing/tests/data/pass/array_constructors.py +++ b/numpy/typing/tests/data/pass/array_constructors.py @@ -1,3 +1,4 @@ +import sys from typing import List, Any import numpy as np @@ -22,8 +23,9 @@ def func(i: int, j: int, **kwargs: Any) -> SubClass: B_stack = np.array([[1], [1]]).view(SubClass) C = [1] -np.ndarray(Index()) -np.ndarray([Index()]) +if sys.version_info >= (3, 8): + np.ndarray(Index()) + np.ndarray([Index()]) np.array(1, dtype=float) np.array(1, copy=False) From 342e9bd76005f270f37dc69cbd664217e9e568ca Mon Sep 17 00:00:00 2001 From: Bas van Beek Date: Sat, 17 Apr 2021 18:43:02 +0200 Subject: [PATCH 13/33] MAINT: Relax the miscellaneous integer-type-constraints --- numpy/__init__.pyi | 85 +++++++++++++++++++++++++++------------------- 1 file changed, 51 insertions(+), 34 deletions(-) diff --git a/numpy/__init__.pyi b/numpy/__init__.pyi index cd6f447d6dcf..9435c27f30ae 100644 --- a/numpy/__init__.pyi +++ b/numpy/__init__.pyi @@ -1014,11 +1014,11 @@ class _ArrayOrScalarCommon: def ravel(self, order: _OrderKACF = ...) -> ndarray: ... @overload def reshape( - self, __shape: Sequence[int], *, order: _OrderACF = ... + self, __shape: _ShapeLike, *, order: _OrderACF = ... ) -> ndarray: ... @overload def reshape( - self, *shape: int, order: _OrderACF = ... + self, *shape: SupportsIndex, order: _OrderACF = ... ) -> ndarray: ... def tobytes(self, order: _OrderKACF = ...) -> bytes: ... # NOTE: `tostring()` is deprecated and therefore excluded @@ -1100,7 +1100,7 @@ class _ArrayOrScalarCommon: ) -> _NdArraySubClass: ... def argsort( self, - axis: Optional[int] = ..., + axis: Optional[SupportsIndex] = ..., kind: Optional[_SortKind] = ..., order: Union[None, str, Sequence[str]] = ..., ) -> ndarray: ... @@ -1146,33 +1146,45 @@ class _ArrayOrScalarCommon: ) -> _NdArraySubClass: ... @overload def compress( - self, a: ArrayLike, axis: Optional[int] = ..., out: None = ..., + self, + a: ArrayLike, + axis: Optional[SupportsIndex] = ..., + out: None = ..., ) -> ndarray: ... @overload def compress( - self, a: ArrayLike, axis: Optional[int] = ..., out: _NdArraySubClass = ..., + self, + a: ArrayLike, + axis: Optional[SupportsIndex] = ..., + out: _NdArraySubClass = ..., ) -> _NdArraySubClass: ... def conj(self: _ArraySelf) -> _ArraySelf: ... def conjugate(self: _ArraySelf) -> _ArraySelf: ... @overload def cumprod( - self, axis: Optional[int] = ..., dtype: DTypeLike = ..., out: None = ..., + self, + axis: Optional[SupportsIndex] = ..., + dtype: DTypeLike = ..., + out: None = ..., ) -> ndarray: ... @overload def cumprod( self, - axis: Optional[int] = ..., + axis: Optional[SupportsIndex] = ..., dtype: DTypeLike = ..., out: _NdArraySubClass = ..., ) -> _NdArraySubClass: ... @overload def cumsum( - self, axis: Optional[int] = ..., dtype: DTypeLike = ..., out: None = ..., + self, + axis: Optional[SupportsIndex] = ..., + dtype: DTypeLike = ..., + out: None = ..., ) -> ndarray: ... @overload def cumsum( self, - axis: Optional[int] = ..., + axis: Optional[SupportsIndex] = ..., dtype: DTypeLike = ..., out: _NdArraySubClass = ..., ) -> _NdArraySubClass: ... @@ -1301,13 +1313,15 @@ class _ArrayOrScalarCommon: keepdims: bool = ..., ) -> _NdArraySubClass: ... def repeat( - self, repeats: _ArrayLikeIntOrBool, axis: Optional[int] = ... + self, repeats: _ArrayLikeIntOrBool, axis: Optional[SupportsIndex] = ... ) -> ndarray: ... @overload - def round(self: _ArraySelf, decimals: int = ..., out: None = ...) -> _ArraySelf: ... + def round( + self: _ArraySelf, decimals: SupportsIndex = ..., out: None = ... + ) -> _ArraySelf: ... @overload def round( - self, decimals: int = ..., out: _NdArraySubClass = ... + self, decimals: SupportsIndex = ..., out: _NdArraySubClass = ... ) -> _NdArraySubClass: ... @overload def std( @@ -1370,7 +1384,7 @@ class _ArrayOrScalarCommon: def take( self, indices: Union[_IntLike, _BoolLike], - axis: Optional[int] = ..., + axis: Optional[SupportsIndex] = ..., out: None = ..., mode: _ModeKind = ..., ) -> generic: ... @@ -1378,7 +1392,7 @@ class _ArrayOrScalarCommon: def take( self, indices: _ArrayLikeIntOrBool, - axis: Optional[int] = ..., + axis: Optional[SupportsIndex] = ..., out: None = ..., mode: _ModeKind = ..., ) -> ndarray: ... @@ -1386,7 +1400,7 @@ class _ArrayOrScalarCommon: def take( self, indices: _ArrayLikeIntOrBool, - axis: Optional[int] = ..., + axis: Optional[SupportsIndex] = ..., out: _NdArraySubClass = ..., mode: _ModeKind = ..., ) -> _NdArraySubClass: ... @@ -1462,37 +1476,40 @@ class ndarray(_ArrayOrScalarCommon, Iterable, Sized, Container): @property def flat(self: _ArraySelf) -> flatiter[_ArraySelf]: ... @overload - def item(self, *args: int) -> Any: ... + def item(self, *args: SupportsIndex) -> Any: ... @overload - def item(self, __args: Tuple[int, ...]) -> Any: ... + def item(self, __args: Tuple[SupportsIndex, ...]) -> Any: ... @overload def itemset(self, __value: Any) -> None: ... @overload def itemset(self, __item: _ShapeLike, __value: Any) -> None: ... @overload - def resize(self, __new_shape: Sequence[int], *, refcheck: bool = ...) -> None: ... + def resize(self, __new_shape: _ShapeLike, *, refcheck: bool = ...) -> None: ... @overload - def resize(self, *new_shape: int, refcheck: bool = ...) -> None: ... + def resize(self, *new_shape: SupportsIndex, refcheck: bool = ...) -> None: ... def setflags( self, write: bool = ..., align: bool = ..., uic: bool = ... ) -> None: ... def squeeze( - self: _ArraySelf, axis: Union[int, Tuple[int, ...]] = ... + self: _ArraySelf, axis: Union[SupportsIndex, Tuple[SupportsIndex, ...]] = ... ) -> _ArraySelf: ... - def swapaxes(self: _ArraySelf, axis1: int, axis2: int) -> _ArraySelf: ... + def swapaxes(self: _ArraySelf, axis1: SupportsIndex, axis2: SupportsIndex) -> _ArraySelf: ... @overload - def transpose(self: _ArraySelf, __axes: Sequence[int]) -> _ArraySelf: ... + def transpose(self: _ArraySelf, __axes: _ShapeLike) -> _ArraySelf: ... @overload - def transpose(self: _ArraySelf, *axes: int) -> _ArraySelf: ... + def transpose(self: _ArraySelf, *axes: SupportsIndex) -> _ArraySelf: ... def argpartition( self, kth: _ArrayLikeIntOrBool, - axis: Optional[int] = ..., + axis: Optional[SupportsIndex] = ..., kind: _PartitionKind = ..., order: Union[None, str, Sequence[str]] = ..., ) -> ndarray: ... def diagonal( - self: _ArraySelf, offset: int = ..., axis1: int = ..., axis2: int = ... + self: _ArraySelf, + offset: SupportsIndex = ..., + axis1: SupportsIndex = ..., + axis2: SupportsIndex = ..., ) -> _ArraySelf: ... @overload def dot(self, b: ArrayLike, out: None = ...) -> Union[number, ndarray]: ... @@ -1503,7 +1520,7 @@ class ndarray(_ArrayOrScalarCommon, Iterable, Sized, Container): def partition( self, kth: _ArrayLikeIntOrBool, - axis: int = ..., + axis: SupportsIndex = ..., kind: _PartitionKind = ..., order: Union[None, str, Sequence[str]] = ..., ) -> None: ... @@ -1519,29 +1536,29 @@ class ndarray(_ArrayOrScalarCommon, Iterable, Sized, Container): sorter: Optional[_ArrayLikeIntOrBool] = ..., # 1D int array ) -> ndarray: ... def setfield( - self, val: ArrayLike, dtype: DTypeLike, offset: int = ... + self, val: ArrayLike, dtype: DTypeLike, offset: SupportsIndex = ... ) -> None: ... def sort( self, - axis: int = ..., + axis: SupportsIndex = ..., kind: Optional[_SortKind] = ..., order: Union[None, str, Sequence[str]] = ..., ) -> None: ... @overload def trace( self, # >= 2D array - offset: int = ..., - axis1: int = ..., - axis2: int = ..., + offset: SupportsIndex = ..., + axis1: SupportsIndex = ..., + axis2: SupportsIndex = ..., dtype: DTypeLike = ..., out: None = ..., ) -> Union[number, ndarray]: ... @overload def trace( self, # >= 2D array - offset: int = ..., - axis1: int = ..., - axis2: int = ..., + offset: SupportsIndex = ..., + axis1: SupportsIndex = ..., + axis2: SupportsIndex = ..., dtype: DTypeLike = ..., out: _NdArraySubClass = ..., ) -> _NdArraySubClass: ... From 99991be3a21f8293fcf4b16663522475b15535a4 Mon Sep 17 00:00:00 2001 From: Bas van Beek Date: Mon, 3 May 2021 01:38:51 +0200 Subject: [PATCH 14/33] TST: Fix a typing failure for python 3.7 Mypy 0.790 does not yet contain annotations for `typing_extensions.SupportsIndex`, so we'll have to define them ourselves --- numpy/typing/_shape.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/numpy/typing/_shape.py b/numpy/typing/_shape.py index b720c3ffc192..cd3ed4c72361 100644 --- a/numpy/typing/_shape.py +++ b/numpy/typing/_shape.py @@ -1,15 +1,15 @@ import sys -from typing import Sequence, Tuple, Union +from typing import Sequence, Tuple, Union, TYPE_CHECKING -if sys.version_info >= (3, 8): - from typing import SupportsIndex -else: - try: - from typing_extensions import SupportsIndex - except ImportError: - SupportsIndex = NotImplemented +if TYPE_CHECKING: + if sys.version_info >= (3, 8): + from typing import SupportsIndex + else: + from typing_extensions import Protocol + class SupportsIndex(Protocol): + def __index__(self) -> int: ... _Shape = Tuple[int, ...] # Anything that can be coerced to a shape tuple -_ShapeLike = Union[SupportsIndex, Sequence[SupportsIndex]] +_ShapeLike = Union["SupportsIndex", Sequence["SupportsIndex"]] From 0e12abde0af454ea63ed41463e540a51733c76fb Mon Sep 17 00:00:00 2001 From: Bas van Beek Date: Wed, 21 Apr 2021 18:05:44 +0200 Subject: [PATCH 15/33] MAINT: Remove unsafe unions from `np.core.fromnumeric` --- numpy/core/fromnumeric.pyi | 350 ++++++------------ numpy/typing/tests/data/fail/fromnumeric.py | 108 +++--- numpy/typing/tests/data/reveal/fromnumeric.py | 270 +++++++------- 3 files changed, 294 insertions(+), 434 deletions(-) diff --git a/numpy/core/fromnumeric.pyi b/numpy/core/fromnumeric.pyi index 66eb3bfb892f..f61d9b7ae779 100644 --- a/numpy/core/fromnumeric.pyi +++ b/numpy/core/fromnumeric.pyi @@ -4,8 +4,7 @@ from typing import Optional, Union, Sequence, Tuple, Any, overload, TypeVar from numpy import ( ndarray, - number, - integer, + signedinteger, bool_, generic, _OrderKACF, @@ -22,8 +21,6 @@ from numpy.typing import ( ArrayLike, _ShapeLike, _Shape, - _IntLike, - _BoolLike, _NumberLike, ) @@ -42,80 +39,58 @@ _ScalarBuiltin = Union[str, bytes, dt.date, dt.timedelta, bool, int, float, comp _Scalar = Union[_ScalarBuiltin, _ScalarNumpy] # Integers and booleans can generally be used interchangeably -_ScalarIntOrBool = TypeVar("_ScalarIntOrBool", bound=Union[integer, bool_]) _ScalarGeneric = TypeVar("_ScalarGeneric", bound=generic) -_ScalarGenericDT = TypeVar( - "_ScalarGenericDT", bound=Union[dt.datetime, dt.timedelta, generic] -) - -_Number = TypeVar("_Number", bound=number) # The signature of take() follows a common theme with its overloads: # 1. A generic comes in; the same generic comes out # 2. A scalar comes in; a generic comes out # 3. An array-like object comes in; some keyword ensures that a generic comes out # 4. An array-like object comes in; an ndarray or generic comes out -@overload -def take( - a: _ScalarGenericDT, - indices: int, - axis: Optional[int] = ..., - out: Optional[ndarray] = ..., - mode: _ModeKind = ..., -) -> _ScalarGenericDT: ... -@overload -def take( - a: _Scalar, - indices: int, - axis: Optional[int] = ..., - out: Optional[ndarray] = ..., - mode: _ModeKind = ..., -) -> _ScalarNumpy: ... -@overload -def take( - a: ArrayLike, - indices: int, - axis: Optional[int] = ..., - out: Optional[ndarray] = ..., - mode: _ModeKind = ..., -) -> _ScalarNumpy: ... -@overload def take( a: ArrayLike, indices: _ArrayLikeIntOrBool, axis: Optional[int] = ..., out: Optional[ndarray] = ..., mode: _ModeKind = ..., -) -> Union[_ScalarNumpy, ndarray]: ... -def reshape(a: ArrayLike, newshape: _ShapeLike, order: _OrderACF = ...) -> ndarray: ... -@overload -def choose( - a: _ScalarIntOrBool, - choices: ArrayLike, - out: Optional[ndarray] = ..., - mode: _ModeKind = ..., -) -> _ScalarIntOrBool: ... -@overload -def choose( - a: Union[_IntLike, _BoolLike], choices: ArrayLike, out: Optional[ndarray] = ..., mode: _ModeKind = ... -) -> Union[integer, bool_]: ... -@overload +) -> Any: ... + +def reshape( + a: ArrayLike, + newshape: _ShapeLike, + order: _OrderACF = ..., +) -> ndarray: ... + def choose( a: _ArrayLikeIntOrBool, choices: ArrayLike, out: Optional[ndarray] = ..., mode: _ModeKind = ..., -) -> ndarray: ... +) -> Any: ... + def repeat( - a: ArrayLike, repeats: _ArrayLikeIntOrBool, axis: Optional[int] = ... + a: ArrayLike, + repeats: _ArrayLikeIntOrBool, + axis: Optional[int] = ..., ) -> ndarray: ... + def put( - a: ndarray, ind: _ArrayLikeIntOrBool, v: ArrayLike, mode: _ModeKind = ... + a: ndarray, + ind: _ArrayLikeIntOrBool, + v: ArrayLike, + mode: _ModeKind = ..., ) -> None: ... -def swapaxes(a: ArrayLike, axis1: int, axis2: int) -> ndarray: ... + +def swapaxes( + a: ArrayLike, + axis1: int, + axis2: int, +) -> ndarray: ... + def transpose( - a: ArrayLike, axes: Union[None, Sequence[int], ndarray] = ... + a: ArrayLike, + axes: Union[None, Sequence[int], ndarray] = ... ) -> ndarray: ... + def partition( a: ArrayLike, kth: _ArrayLikeIntOrBool, @@ -123,61 +98,62 @@ def partition( kind: _PartitionKind = ..., order: Union[None, str, Sequence[str]] = ..., ) -> ndarray: ... -@overload -def argpartition( - a: generic, - kth: _ArrayLikeIntOrBool, - axis: Optional[int] = ..., - kind: _PartitionKind = ..., - order: Union[None, str, Sequence[str]] = ..., -) -> integer: ... -@overload -def argpartition( - a: _ScalarBuiltin, - kth: _ArrayLikeIntOrBool, - axis: Optional[int] = ..., - kind: _PartitionKind = ..., - order: Union[None, str, Sequence[str]] = ..., -) -> ndarray: ... -@overload + def argpartition( a: ArrayLike, kth: _ArrayLikeIntOrBool, axis: Optional[int] = ..., kind: _PartitionKind = ..., order: Union[None, str, Sequence[str]] = ..., -) -> ndarray: ... +) -> Any: ... + def sort( a: ArrayLike, axis: Optional[int] = ..., kind: Optional[_SortKind] = ..., order: Union[None, str, Sequence[str]] = ..., ) -> ndarray: ... + def argsort( a: ArrayLike, axis: Optional[int] = ..., kind: Optional[_SortKind] = ..., order: Union[None, str, Sequence[str]] = ..., ) -> ndarray: ... + @overload -def argmax(a: ArrayLike, axis: None = ..., out: Optional[ndarray] = ...) -> integer: ... +def argmax( + a: ArrayLike, + axis: None = ..., + out: Optional[ndarray] = ..., +) -> signedinteger[Any]: ... @overload def argmax( - a: ArrayLike, axis: int = ..., out: Optional[ndarray] = ... -) -> Union[integer, ndarray]: ... + a: ArrayLike, + axis: Optional[int] = ..., + out: Optional[ndarray] = ..., +) -> Any: ... + @overload -def argmin(a: ArrayLike, axis: None = ..., out: Optional[ndarray] = ...) -> integer: ... +def argmin( + a: ArrayLike, + axis: None = ..., + out: Optional[ndarray] = ..., +) -> signedinteger[Any]: ... @overload def argmin( - a: ArrayLike, axis: int = ..., out: Optional[ndarray] = ... -) -> Union[integer, ndarray]: ... + a: ArrayLike, + axis: Optional[int] = ..., + out: Optional[ndarray] = ..., +) -> Any: ... + @overload def searchsorted( a: ArrayLike, v: _Scalar, side: _SortSide = ..., sorter: Optional[_ArrayLikeIntOrBool] = ..., # 1D int array -) -> integer: ... +) -> signedinteger[Any]: ... @overload def searchsorted( a: ArrayLike, @@ -185,14 +161,30 @@ def searchsorted( side: _SortSide = ..., sorter: Optional[_ArrayLikeIntOrBool] = ..., # 1D int array ) -> ndarray: ... -def resize(a: ArrayLike, new_shape: _ShapeLike) -> ndarray: ... + +def resize( + a: ArrayLike, + new_shape: _ShapeLike, +) -> ndarray: ... + @overload -def squeeze(a: _ScalarGeneric, axis: Optional[_ShapeLike] = ...) -> _ScalarGeneric: ... +def squeeze( + a: _ScalarGeneric, + axis: Optional[_ShapeLike] = ..., +) -> _ScalarGeneric: ... @overload -def squeeze(a: ArrayLike, axis: Optional[_ShapeLike] = ...) -> ndarray: ... +def squeeze( + a: ArrayLike, + axis: Optional[_ShapeLike] = ..., +) -> ndarray: ... + def diagonal( - a: ArrayLike, offset: int = ..., axis1: int = ..., axis2: int = ... # >= 2D array + a: ArrayLike, + offset: int = ..., + axis1: int = ..., + axis2: int = ..., # >= 2D array ) -> ndarray: ... + def trace( a: ArrayLike, # >= 2D array offset: int = ..., @@ -200,32 +192,21 @@ def trace( axis2: int = ..., dtype: DTypeLike = ..., out: Optional[ndarray] = ..., -) -> Union[number, ndarray]: ... +) -> Any: ... + def ravel(a: ArrayLike, order: _OrderKACF = ...) -> ndarray: ... + def nonzero(a: ArrayLike) -> Tuple[ndarray, ...]: ... + def shape(a: ArrayLike) -> _Shape: ... + def compress( condition: ArrayLike, # 1D bool array a: ArrayLike, axis: Optional[int] = ..., out: Optional[ndarray] = ..., ) -> ndarray: ... -@overload -def clip( - a: _Number, - a_min: ArrayLike, - a_max: Optional[ArrayLike], - out: Optional[ndarray] = ..., - **kwargs: Any, -) -> _Number: ... -@overload -def clip( - a: _Number, - a_min: None, - a_max: ArrayLike, - out: Optional[ndarray] = ..., - **kwargs: Any, -) -> _Number: ... + @overload def clip( a: ArrayLike, @@ -233,7 +214,7 @@ def clip( a_max: Optional[ArrayLike], out: Optional[ndarray] = ..., **kwargs: Any, -) -> Union[number, ndarray]: ... +) -> Any: ... @overload def clip( a: ArrayLike, @@ -241,18 +222,8 @@ def clip( a_max: ArrayLike, out: Optional[ndarray] = ..., **kwargs: Any, -) -> Union[number, ndarray]: ... -@overload -def sum( - a: _Number, - axis: Optional[_ShapeLike] = ..., - dtype: DTypeLike = ..., - out: Optional[ndarray] = ..., - keepdims: bool = ..., - initial: _NumberLike = ..., - where: _ArrayLikeBool = ..., -) -> _Number: ... -@overload +) -> Any: ... + def sum( a: ArrayLike, axis: _ShapeLike = ..., @@ -261,12 +232,13 @@ def sum( keepdims: bool = ..., initial: _NumberLike = ..., where: _ArrayLikeBool = ..., -) -> Union[number, ndarray]: ... +) -> Any: ... + @overload def all( a: ArrayLike, axis: None = ..., - out: Optional[ndarray] = ..., + out: None = ..., keepdims: Literal[False] = ..., ) -> bool_: ... @overload @@ -275,12 +247,13 @@ def all( axis: Optional[_ShapeLike] = ..., out: Optional[ndarray] = ..., keepdims: bool = ..., -) -> Union[bool_, ndarray]: ... +) -> Any: ... + @overload def any( a: ArrayLike, axis: None = ..., - out: Optional[ndarray] = ..., + out: None = ..., keepdims: Literal[False] = ..., ) -> bool_: ... @overload @@ -289,53 +262,22 @@ def any( axis: Optional[_ShapeLike] = ..., out: Optional[ndarray] = ..., keepdims: bool = ..., -) -> Union[bool_, ndarray]: ... +) -> Any: ... + def cumsum( a: ArrayLike, axis: Optional[int] = ..., dtype: DTypeLike = ..., out: Optional[ndarray] = ..., ) -> ndarray: ... -@overload -def ptp( - a: _Number, - axis: Optional[_ShapeLike] = ..., - out: Optional[ndarray] = ..., - keepdims: bool = ..., -) -> _Number: ... -@overload -def ptp( - a: ArrayLike, - axis: None = ..., - out: Optional[ndarray] = ..., - keepdims: Literal[False] = ..., -) -> number: ... -@overload + def ptp( a: ArrayLike, axis: Optional[_ShapeLike] = ..., out: Optional[ndarray] = ..., keepdims: bool = ..., -) -> Union[number, ndarray]: ... -@overload -def amax( - a: _Number, - axis: Optional[_ShapeLike] = ..., - out: Optional[ndarray] = ..., - keepdims: bool = ..., - initial: _NumberLike = ..., - where: _ArrayLikeBool = ..., -) -> _Number: ... -@overload -def amax( - a: ArrayLike, - axis: None = ..., - out: Optional[ndarray] = ..., - keepdims: Literal[False] = ..., - initial: _NumberLike = ..., - where: _ArrayLikeBool = ..., -) -> number: ... -@overload +) -> Any: ... + def amax( a: ArrayLike, axis: Optional[_ShapeLike] = ..., @@ -343,26 +285,8 @@ def amax( keepdims: bool = ..., initial: _NumberLike = ..., where: _ArrayLikeBool = ..., -) -> Union[number, ndarray]: ... -@overload -def amin( - a: _Number, - axis: Optional[_ShapeLike] = ..., - out: Optional[ndarray] = ..., - keepdims: bool = ..., - initial: _NumberLike = ..., - where: _ArrayLikeBool = ..., -) -> _Number: ... -@overload -def amin( - a: ArrayLike, - axis: None = ..., - out: Optional[ndarray] = ..., - keepdims: Literal[False] = ..., - initial: _NumberLike = ..., - where: _ArrayLikeBool = ..., -) -> number: ... -@overload +) -> Any: ... + def amin( a: ArrayLike, axis: Optional[_ShapeLike] = ..., @@ -370,7 +294,7 @@ def amin( keepdims: bool = ..., initial: _NumberLike = ..., where: _ArrayLikeBool = ..., -) -> Union[number, ndarray]: ... +) -> Any: ... # TODO: `np.prod()``: For object arrays `initial` does not necessarily # have to be a numerical scalar. @@ -379,27 +303,6 @@ def amin( # Note that the same situation holds for all wrappers around # `np.ufunc.reduce`, e.g. `np.sum()` (`.__add__()`). -@overload -def prod( - a: _Number, - axis: Optional[_ShapeLike] = ..., - dtype: DTypeLike = ..., - out: None = ..., - keepdims: bool = ..., - initial: _NumberLike = ..., - where: _ArrayLikeBool = ..., -) -> _Number: ... -@overload -def prod( - a: ArrayLike, - axis: None = ..., - dtype: DTypeLike = ..., - out: None = ..., - keepdims: Literal[False] = ..., - initial: _NumberLike = ..., - where: _ArrayLikeBool = ..., -) -> number: ... -@overload def prod( a: ArrayLike, axis: Optional[_ShapeLike] = ..., @@ -408,53 +311,33 @@ def prod( keepdims: bool = ..., initial: _NumberLike = ..., where: _ArrayLikeBool = ..., -) -> Union[number, ndarray]: ... +) -> Any: ... + def cumprod( a: ArrayLike, axis: Optional[int] = ..., dtype: DTypeLike = ..., out: Optional[ndarray] = ..., ) -> ndarray: ... + def ndim(a: ArrayLike) -> int: ... + def size(a: ArrayLike, axis: Optional[int] = ...) -> int: ... -@overload -def around( - a: _Number, decimals: int = ..., out: Optional[ndarray] = ... -) -> _Number: ... -@overload -def around( - a: _NumberLike, decimals: int = ..., out: Optional[ndarray] = ... -) -> number: ... -@overload + def around( - a: ArrayLike, decimals: int = ..., out: Optional[ndarray] = ... -) -> ndarray: ... -@overload -def mean( a: ArrayLike, - axis: None = ..., - dtype: DTypeLike = ..., - out: None = ..., - keepdims: Literal[False] = ..., -) -> number: ... -@overload + decimals: int = ..., + out: Optional[ndarray] = ..., +) -> Any: ... + def mean( a: ArrayLike, axis: Optional[_ShapeLike] = ..., dtype: DTypeLike = ..., out: Optional[ndarray] = ..., keepdims: bool = ..., -) -> Union[number, ndarray]: ... -@overload -def std( - a: ArrayLike, - axis: None = ..., - dtype: DTypeLike = ..., - out: None = ..., - ddof: int = ..., - keepdims: Literal[False] = ..., -) -> number: ... -@overload +) -> Any: ... + def std( a: ArrayLike, axis: Optional[_ShapeLike] = ..., @@ -462,17 +345,8 @@ def std( out: Optional[ndarray] = ..., ddof: int = ..., keepdims: bool = ..., -) -> Union[number, ndarray]: ... -@overload -def var( - a: ArrayLike, - axis: None = ..., - dtype: DTypeLike = ..., - out: None = ..., - ddof: int = ..., - keepdims: Literal[False] = ..., -) -> number: ... -@overload +) -> Any: ... + def var( a: ArrayLike, axis: Optional[_ShapeLike] = ..., @@ -480,4 +354,4 @@ def var( out: Optional[ndarray] = ..., ddof: int = ..., keepdims: bool = ..., -) -> Union[number, ndarray]: ... +) -> Any: ... diff --git a/numpy/typing/tests/data/fail/fromnumeric.py b/numpy/typing/tests/data/fail/fromnumeric.py index c9156895dd51..d8f7a5d69eba 100644 --- a/numpy/typing/tests/data/fail/fromnumeric.py +++ b/numpy/typing/tests/data/fail/fromnumeric.py @@ -7,17 +7,17 @@ a = np.bool_(True) -np.take(a, None) # E: No overload variant of "take" matches argument type -np.take(a, axis=1.0) # E: No overload variant of "take" matches argument type -np.take(A, out=1) # E: No overload variant of "take" matches argument type -np.take(A, mode="bob") # E: No overload variant of "take" matches argument type +np.take(a, None) # E: incompatible type +np.take(a, axis=1.0) # E: incompatible type +np.take(A, out=1) # E: incompatible type +np.take(A, mode="bob") # E: incompatible type np.reshape(a, None) # E: Argument 2 to "reshape" has incompatible type np.reshape(A, 1, order="bob") # E: Argument "order" to "reshape" has incompatible type -np.choose(a, None) # E: No overload variant of "choose" matches argument type -np.choose(a, out=1.0) # E: No overload variant of "choose" matches argument type -np.choose(A, mode="bob") # E: No overload variant of "choose" matches argument type +np.choose(a, None) # E: incompatible type +np.choose(a, out=1.0) # E: incompatible type +np.choose(A, mode="bob") # E: incompatible type np.repeat(a, None) # E: Argument 2 to "repeat" has incompatible type np.repeat(A, 1, axis=1.0) # E: Argument "axis" to "repeat" has incompatible type @@ -38,14 +38,14 @@ A, 0, order=range(5) # E: Argument "order" to "partition" has incompatible type ) -np.argpartition( # E: No overload variant of "argpartition" matches argument type - a, None +np.argpartition( + a, None # E: incompatible type ) -np.argpartition( # E: No overload variant of "argpartition" matches argument type - a, 0, axis="bob" +np.argpartition( + a, 0, axis="bob" # E: incompatible type ) -np.argpartition( # E: No overload variant of "argpartition" matches argument type - A, 0, kind="bob" +np.argpartition( + A, 0, kind="bob" # E: incompatible type ) np.argpartition( A, 0, order=range(5) # E: Argument "order" to "argpartition" has incompatible type @@ -93,62 +93,62 @@ np.clip(a, 1, 2, out=1) # E: No overload variant of "clip" matches argument type np.clip(1, None, None) # E: No overload variant of "clip" matches argument type -np.sum(a, axis=1.0) # E: No overload variant of "sum" matches argument type -np.sum(a, keepdims=1.0) # E: No overload variant of "sum" matches argument type -np.sum(a, initial=[1]) # E: No overload variant of "sum" matches argument type +np.sum(a, axis=1.0) # E: incompatible type +np.sum(a, keepdims=1.0) # E: incompatible type +np.sum(a, initial=[1]) # E: incompatible type -np.all(a, axis=1.0) # E: No overload variant of "all" matches argument type -np.all(a, keepdims=1.0) # E: No overload variant of "all" matches argument type -np.all(a, out=1.0) # E: No overload variant of "all" matches argument type +np.all(a, axis=1.0) # E: No overload variant +np.all(a, keepdims=1.0) # E: No overload variant +np.all(a, out=1.0) # E: No overload variant -np.any(a, axis=1.0) # E: No overload variant of "any" matches argument type -np.any(a, keepdims=1.0) # E: No overload variant of "any" matches argument type -np.any(a, out=1.0) # E: No overload variant of "any" matches argument type +np.any(a, axis=1.0) # E: No overload variant +np.any(a, keepdims=1.0) # E: No overload variant +np.any(a, out=1.0) # E: No overload variant -np.cumsum(a, axis=1.0) # E: Argument "axis" to "cumsum" has incompatible type -np.cumsum(a, dtype=1.0) # E: Argument "dtype" to "cumsum" has incompatible type -np.cumsum(a, out=1.0) # E: Argument "out" to "cumsum" has incompatible type +np.cumsum(a, axis=1.0) # E: incompatible type +np.cumsum(a, dtype=1.0) # E: incompatible type +np.cumsum(a, out=1.0) # E: incompatible type -np.ptp(a, axis=1.0) # E: No overload variant of "ptp" matches argument type -np.ptp(a, keepdims=1.0) # E: No overload variant of "ptp" matches argument type -np.ptp(a, out=1.0) # E: No overload variant of "ptp" matches argument type +np.ptp(a, axis=1.0) # E: incompatible type +np.ptp(a, keepdims=1.0) # E: incompatible type +np.ptp(a, out=1.0) # E: incompatible type -np.amax(a, axis=1.0) # E: No overload variant of "amax" matches argument type -np.amax(a, keepdims=1.0) # E: No overload variant of "amax" matches argument type -np.amax(a, out=1.0) # E: No overload variant of "amax" matches argument type -np.amax(a, initial=[1.0]) # E: No overload variant of "amax" matches argument type +np.amax(a, axis=1.0) # E: incompatible type +np.amax(a, keepdims=1.0) # E: incompatible type +np.amax(a, out=1.0) # E: incompatible type +np.amax(a, initial=[1.0]) # E: incompatible type np.amax(a, where=[1.0]) # E: List item 0 has incompatible type -np.amin(a, axis=1.0) # E: No overload variant of "amin" matches argument type -np.amin(a, keepdims=1.0) # E: No overload variant of "amin" matches argument type -np.amin(a, out=1.0) # E: No overload variant of "amin" matches argument type -np.amin(a, initial=[1.0]) # E: No overload variant of "amin" matches argument type +np.amin(a, axis=1.0) # E: incompatible type +np.amin(a, keepdims=1.0) # E: incompatible type +np.amin(a, out=1.0) # E: incompatible type +np.amin(a, initial=[1.0]) # E: incompatible type np.amin(a, where=[1.0]) # E: List item 0 has incompatible type -np.prod(a, axis=1.0) # E: No overload variant of "prod" matches argument type -np.prod(a, out=False) # E: No overload variant of "prod" matches argument type -np.prod(a, keepdims=1.0) # E: No overload variant of "prod" matches argument type -np.prod(a, initial=int) # E: No overload variant of "prod" matches argument type -np.prod(a, where=1.0) # E: No overload variant of "prod" matches argument type +np.prod(a, axis=1.0) # E: incompatible type +np.prod(a, out=False) # E: incompatible type +np.prod(a, keepdims=1.0) # E: incompatible type +np.prod(a, initial=int) # E: incompatible type +np.prod(a, where=1.0) # E: incompatible type np.cumprod(a, axis=1.0) # E: Argument "axis" to "cumprod" has incompatible type np.cumprod(a, out=False) # E: Argument "out" to "cumprod" has incompatible type np.size(a, axis=1.0) # E: Argument "axis" to "size" has incompatible type -np.around(a, decimals=1.0) # E: No overload variant of "around" matches argument type -np.around(a, out=type) # E: No overload variant of "around" matches argument type +np.around(a, decimals=1.0) # E: incompatible type +np.around(a, out=type) # E: incompatible type -np.mean(a, axis=1.0) # E: No overload variant of "mean" matches argument type -np.mean(a, out=False) # E: No overload variant of "mean" matches argument type -np.mean(a, keepdims=1.0) # E: No overload variant of "mean" matches argument type +np.mean(a, axis=1.0) # E: incompatible type +np.mean(a, out=False) # E: incompatible type +np.mean(a, keepdims=1.0) # E: incompatible type -np.std(a, axis=1.0) # E: No overload variant of "std" matches argument type -np.std(a, out=False) # E: No overload variant of "std" matches argument type -np.std(a, ddof='test') # E: No overload variant of "std" matches argument type -np.std(a, keepdims=1.0) # E: No overload variant of "std" matches argument type +np.std(a, axis=1.0) # E: incompatible type +np.std(a, out=False) # E: incompatible type +np.std(a, ddof='test') # E: incompatible type +np.std(a, keepdims=1.0) # E: incompatible type -np.var(a, axis=1.0) # E: No overload variant of "var" matches argument type -np.var(a, out=False) # E: No overload variant of "var" matches argument type -np.var(a, ddof='test') # E: No overload variant of "var" matches argument type -np.var(a, keepdims=1.0) # E: No overload variant of "var" matches argument type +np.var(a, axis=1.0) # E: incompatible type +np.var(a, out=False) # E: incompatible type +np.var(a, ddof='test') # E: incompatible type +np.var(a, keepdims=1.0) # E: incompatible type diff --git a/numpy/typing/tests/data/reveal/fromnumeric.py b/numpy/typing/tests/data/reveal/fromnumeric.py index 75865c285f36..5d67ab97fec8 100644 --- a/numpy/typing/tests/data/reveal/fromnumeric.py +++ b/numpy/typing/tests/data/reveal/fromnumeric.py @@ -12,27 +12,13 @@ c = 1.0 d = np.array(1.0, dtype=np.float32) # writeable -reveal_type(np.take(a, 0)) # E: numpy.bool_ -reveal_type(np.take(b, 0)) # E: numpy.floating[numpy.typing._32Bit] -reveal_type( - np.take(c, 0) # E: Union[numpy.generic, datetime.datetime, datetime.timedelta] -) -reveal_type( - np.take(A, 0) # E: Union[numpy.generic, datetime.datetime, datetime.timedelta] -) -reveal_type( - np.take(B, 0) # E: Union[numpy.generic, datetime.datetime, datetime.timedelta] -) -reveal_type( - np.take( # E: Union[Union[numpy.generic, datetime.datetime, datetime.timedelta], numpy.ndarray] - A, [0] - ) -) -reveal_type( - np.take( # E: Union[Union[numpy.generic, datetime.datetime, datetime.timedelta], numpy.ndarray] - B, [0] - ) -) +reveal_type(np.take(a, 0)) # E: Any +reveal_type(np.take(b, 0)) # E: Any +reveal_type(np.take(c, 0)) # E: Any +reveal_type(np.take(A, 0)) # E: Any +reveal_type(np.take(B, 0)) # E: Any +reveal_type(np.take(A, [0])) # E: Any +reveal_type(np.take(B, [0])) # E: Any reveal_type(np.reshape(a, 1)) # E: numpy.ndarray reveal_type(np.reshape(b, 1)) # E: numpy.ndarray @@ -40,8 +26,8 @@ reveal_type(np.reshape(A, 1)) # E: numpy.ndarray reveal_type(np.reshape(B, 1)) # E: numpy.ndarray -reveal_type(np.choose(a, [True, True])) # E: numpy.bool_ -reveal_type(np.choose(A, [True, True])) # E: numpy.ndarray +reveal_type(np.choose(a, [True, True])) # E: Any +reveal_type(np.choose(A, [True, True])) # E: Any reveal_type(np.repeat(a, 1)) # E: numpy.ndarray reveal_type(np.repeat(b, 1)) # E: numpy.ndarray @@ -66,11 +52,11 @@ reveal_type(np.partition(A, 0)) # E: numpy.ndarray reveal_type(np.partition(B, 0)) # E: numpy.ndarray -reveal_type(np.argpartition(a, 0)) # E: numpy.integer[Any] -reveal_type(np.argpartition(b, 0)) # E: numpy.integer[Any] -reveal_type(np.argpartition(c, 0)) # E: numpy.ndarray -reveal_type(np.argpartition(A, 0)) # E: numpy.ndarray -reveal_type(np.argpartition(B, 0)) # E: numpy.ndarray +reveal_type(np.argpartition(a, 0)) # E: Any +reveal_type(np.argpartition(b, 0)) # E: Any +reveal_type(np.argpartition(c, 0)) # E: Any +reveal_type(np.argpartition(A, 0)) # E: Any +reveal_type(np.argpartition(B, 0)) # E: Any reveal_type(np.sort(A, 0)) # E: numpy.ndarray reveal_type(np.sort(B, 0)) # E: numpy.ndarray @@ -78,18 +64,18 @@ reveal_type(np.argsort(A, 0)) # E: numpy.ndarray reveal_type(np.argsort(B, 0)) # E: numpy.ndarray -reveal_type(np.argmax(A)) # E: numpy.integer[Any] -reveal_type(np.argmax(B)) # E: numpy.integer[Any] -reveal_type(np.argmax(A, axis=0)) # E: Union[numpy.integer[Any], numpy.ndarray] -reveal_type(np.argmax(B, axis=0)) # E: Union[numpy.integer[Any], numpy.ndarray] +reveal_type(np.argmax(A)) # E: numpy.signedinteger[Any] +reveal_type(np.argmax(B)) # E: numpy.signedinteger[Any] +reveal_type(np.argmax(A, axis=0)) # E: Any +reveal_type(np.argmax(B, axis=0)) # E: Any -reveal_type(np.argmin(A)) # E: numpy.integer[Any] -reveal_type(np.argmin(B)) # E: numpy.integer[Any] -reveal_type(np.argmin(A, axis=0)) # E: Union[numpy.integer[Any], numpy.ndarray] -reveal_type(np.argmin(B, axis=0)) # E: Union[numpy.integer[Any], numpy.ndarray] +reveal_type(np.argmin(A)) # E: numpy.signedinteger[Any] +reveal_type(np.argmin(B)) # E: numpy.signedinteger[Any] +reveal_type(np.argmin(A, axis=0)) # E: Any +reveal_type(np.argmin(B, axis=0)) # E: Any -reveal_type(np.searchsorted(A[0], 0)) # E: numpy.integer[Any] -reveal_type(np.searchsorted(B[0], 0)) # E: numpy.integer[Any] +reveal_type(np.searchsorted(A[0], 0)) # E: numpy.signedinteger[Any] +reveal_type(np.searchsorted(B[0], 0)) # E: numpy.signedinteger[Any] reveal_type(np.searchsorted(A[0], [0])) # E: numpy.ndarray reveal_type(np.searchsorted(B[0], [0])) # E: numpy.ndarray @@ -108,8 +94,8 @@ reveal_type(np.diagonal(A)) # E: numpy.ndarray reveal_type(np.diagonal(B)) # E: numpy.ndarray -reveal_type(np.trace(A)) # E: Union[numpy.number[Any], numpy.ndarray] -reveal_type(np.trace(B)) # E: Union[numpy.number[Any], numpy.ndarray] +reveal_type(np.trace(A)) # E: Any +reveal_type(np.trace(B)) # E: Any reveal_type(np.ravel(a)) # E: numpy.ndarray reveal_type(np.ravel(b)) # E: numpy.ndarray @@ -135,39 +121,39 @@ reveal_type(np.compress([True], A)) # E: numpy.ndarray reveal_type(np.compress([True], B)) # E: numpy.ndarray -reveal_type(np.clip(a, 0, 1.0)) # E: numpy.number[Any] -reveal_type(np.clip(b, -1, 1)) # E: numpy.floating[numpy.typing._32Bit] -reveal_type(np.clip(c, 0, 1)) # E: numpy.number[Any] -reveal_type(np.clip(A, 0, 1)) # E: Union[numpy.number[Any], numpy.ndarray] -reveal_type(np.clip(B, 0, 1)) # E: Union[numpy.number[Any], numpy.ndarray] +reveal_type(np.clip(a, 0, 1.0)) # E: Any +reveal_type(np.clip(b, -1, 1)) # E: Any +reveal_type(np.clip(c, 0, 1)) # E: Any +reveal_type(np.clip(A, 0, 1)) # E: Any +reveal_type(np.clip(B, 0, 1)) # E: Any -reveal_type(np.sum(a)) # E: numpy.number[Any] -reveal_type(np.sum(b)) # E: numpy.floating[numpy.typing._32Bit] -reveal_type(np.sum(c)) # E: numpy.number[Any] -reveal_type(np.sum(A)) # E: numpy.number[Any] -reveal_type(np.sum(B)) # E: numpy.number[Any] -reveal_type(np.sum(A, axis=0)) # E: Union[numpy.number[Any], numpy.ndarray] -reveal_type(np.sum(B, axis=0)) # E: Union[numpy.number[Any], numpy.ndarray] +reveal_type(np.sum(a)) # E: Any +reveal_type(np.sum(b)) # E: Any +reveal_type(np.sum(c)) # E: Any +reveal_type(np.sum(A)) # E: Any +reveal_type(np.sum(B)) # E: Any +reveal_type(np.sum(A, axis=0)) # E: Any +reveal_type(np.sum(B, axis=0)) # E: Any reveal_type(np.all(a)) # E: numpy.bool_ reveal_type(np.all(b)) # E: numpy.bool_ reveal_type(np.all(c)) # E: numpy.bool_ reveal_type(np.all(A)) # E: numpy.bool_ reveal_type(np.all(B)) # E: numpy.bool_ -reveal_type(np.all(A, axis=0)) # E: Union[numpy.bool_, numpy.ndarray] -reveal_type(np.all(B, axis=0)) # E: Union[numpy.bool_, numpy.ndarray] -reveal_type(np.all(A, keepdims=True)) # E: Union[numpy.bool_, numpy.ndarray] -reveal_type(np.all(B, keepdims=True)) # E: Union[numpy.bool_, numpy.ndarray] +reveal_type(np.all(A, axis=0)) # E: Any +reveal_type(np.all(B, axis=0)) # E: Any +reveal_type(np.all(A, keepdims=True)) # E: Any +reveal_type(np.all(B, keepdims=True)) # E: Any reveal_type(np.any(a)) # E: numpy.bool_ reveal_type(np.any(b)) # E: numpy.bool_ reveal_type(np.any(c)) # E: numpy.bool_ reveal_type(np.any(A)) # E: numpy.bool_ reveal_type(np.any(B)) # E: numpy.bool_ -reveal_type(np.any(A, axis=0)) # E: Union[numpy.bool_, numpy.ndarray] -reveal_type(np.any(B, axis=0)) # E: Union[numpy.bool_, numpy.ndarray] -reveal_type(np.any(A, keepdims=True)) # E: Union[numpy.bool_, numpy.ndarray] -reveal_type(np.any(B, keepdims=True)) # E: Union[numpy.bool_, numpy.ndarray] +reveal_type(np.any(A, axis=0)) # E: Any +reveal_type(np.any(B, axis=0)) # E: Any +reveal_type(np.any(A, keepdims=True)) # E: Any +reveal_type(np.any(B, keepdims=True)) # E: Any reveal_type(np.cumsum(a)) # E: numpy.ndarray reveal_type(np.cumsum(b)) # E: numpy.ndarray @@ -175,47 +161,47 @@ reveal_type(np.cumsum(A)) # E: numpy.ndarray reveal_type(np.cumsum(B)) # E: numpy.ndarray -reveal_type(np.ptp(a)) # E: numpy.number[Any] -reveal_type(np.ptp(b)) # E: numpy.floating[numpy.typing._32Bit] -reveal_type(np.ptp(c)) # E: numpy.number[Any] -reveal_type(np.ptp(A)) # E: numpy.number[Any] -reveal_type(np.ptp(B)) # E: numpy.number[Any] -reveal_type(np.ptp(A, axis=0)) # E: Union[numpy.number[Any], numpy.ndarray] -reveal_type(np.ptp(B, axis=0)) # E: Union[numpy.number[Any], numpy.ndarray] -reveal_type(np.ptp(A, keepdims=True)) # E: Union[numpy.number[Any], numpy.ndarray] -reveal_type(np.ptp(B, keepdims=True)) # E: Union[numpy.number[Any], numpy.ndarray] - -reveal_type(np.amax(a)) # E: numpy.number[Any] -reveal_type(np.amax(b)) # E: numpy.floating[numpy.typing._32Bit] -reveal_type(np.amax(c)) # E: numpy.number[Any] -reveal_type(np.amax(A)) # E: numpy.number[Any] -reveal_type(np.amax(B)) # E: numpy.number[Any] -reveal_type(np.amax(A, axis=0)) # E: Union[numpy.number[Any], numpy.ndarray] -reveal_type(np.amax(B, axis=0)) # E: Union[numpy.number[Any], numpy.ndarray] -reveal_type(np.amax(A, keepdims=True)) # E: Union[numpy.number[Any], numpy.ndarray] -reveal_type(np.amax(B, keepdims=True)) # E: Union[numpy.number[Any], numpy.ndarray] - -reveal_type(np.amin(a)) # E: numpy.number[Any] -reveal_type(np.amin(b)) # E: numpy.floating[numpy.typing._32Bit] -reveal_type(np.amin(c)) # E: numpy.number[Any] -reveal_type(np.amin(A)) # E: numpy.number[Any] -reveal_type(np.amin(B)) # E: numpy.number[Any] -reveal_type(np.amin(A, axis=0)) # E: Union[numpy.number[Any], numpy.ndarray] -reveal_type(np.amin(B, axis=0)) # E: Union[numpy.number[Any], numpy.ndarray] -reveal_type(np.amin(A, keepdims=True)) # E: Union[numpy.number[Any], numpy.ndarray] -reveal_type(np.amin(B, keepdims=True)) # E: Union[numpy.number[Any], numpy.ndarray] - -reveal_type(np.prod(a)) # E: numpy.number[Any] -reveal_type(np.prod(b)) # E: numpy.floating[numpy.typing._32Bit] -reveal_type(np.prod(c)) # E: numpy.number[Any] -reveal_type(np.prod(A)) # E: numpy.number[Any] -reveal_type(np.prod(B)) # E: numpy.number[Any] -reveal_type(np.prod(A, axis=0)) # E: Union[numpy.number[Any], numpy.ndarray] -reveal_type(np.prod(B, axis=0)) # E: Union[numpy.number[Any], numpy.ndarray] -reveal_type(np.prod(A, keepdims=True)) # E: Union[numpy.number[Any], numpy.ndarray] -reveal_type(np.prod(B, keepdims=True)) # E: Union[numpy.number[Any], numpy.ndarray] -reveal_type(np.prod(b, out=d)) # E: numpy.ndarray -reveal_type(np.prod(B, out=d)) # E: numpy.ndarray +reveal_type(np.ptp(a)) # E: Any +reveal_type(np.ptp(b)) # E: Any +reveal_type(np.ptp(c)) # E: Any +reveal_type(np.ptp(A)) # E: Any +reveal_type(np.ptp(B)) # E: Any +reveal_type(np.ptp(A, axis=0)) # E: Any +reveal_type(np.ptp(B, axis=0)) # E: Any +reveal_type(np.ptp(A, keepdims=True)) # E: Any +reveal_type(np.ptp(B, keepdims=True)) # E: Any + +reveal_type(np.amax(a)) # E: Any +reveal_type(np.amax(b)) # E: Any +reveal_type(np.amax(c)) # E: Any +reveal_type(np.amax(A)) # E: Any +reveal_type(np.amax(B)) # E: Any +reveal_type(np.amax(A, axis=0)) # E: Any +reveal_type(np.amax(B, axis=0)) # E: Any +reveal_type(np.amax(A, keepdims=True)) # E: Any +reveal_type(np.amax(B, keepdims=True)) # E: Any + +reveal_type(np.amin(a)) # E: Any +reveal_type(np.amin(b)) # E: Any +reveal_type(np.amin(c)) # E: Any +reveal_type(np.amin(A)) # E: Any +reveal_type(np.amin(B)) # E: Any +reveal_type(np.amin(A, axis=0)) # E: Any +reveal_type(np.amin(B, axis=0)) # E: Any +reveal_type(np.amin(A, keepdims=True)) # E: Any +reveal_type(np.amin(B, keepdims=True)) # E: Any + +reveal_type(np.prod(a)) # E: Any +reveal_type(np.prod(b)) # E: Any +reveal_type(np.prod(c)) # E: Any +reveal_type(np.prod(A)) # E: Any +reveal_type(np.prod(B)) # E: Any +reveal_type(np.prod(A, axis=0)) # E: Any +reveal_type(np.prod(B, axis=0)) # E: Any +reveal_type(np.prod(A, keepdims=True)) # E: Any +reveal_type(np.prod(B, keepdims=True)) # E: Any +reveal_type(np.prod(b, out=d)) # E: Any +reveal_type(np.prod(B, out=d)) # E: Any reveal_type(np.cumprod(a)) # E: numpy.ndarray reveal_type(np.cumprod(b)) # E: numpy.ndarray @@ -235,44 +221,44 @@ reveal_type(np.size(A)) # E: int reveal_type(np.size(B)) # E: int -reveal_type(np.around(a)) # E: numpy.number[Any] -reveal_type(np.around(b)) # E: numpy.floating[numpy.typing._32Bit] -reveal_type(np.around(c)) # E: numpy.number[Any] -reveal_type(np.around(A)) # E: numpy.ndarray -reveal_type(np.around(B)) # E: numpy.ndarray - -reveal_type(np.mean(a)) # E: numpy.number[Any] -reveal_type(np.mean(b)) # E: numpy.number[Any] -reveal_type(np.mean(c)) # E: numpy.number[Any] -reveal_type(np.mean(A)) # E: numpy.number[Any] -reveal_type(np.mean(B)) # E: numpy.number[Any] -reveal_type(np.mean(A, axis=0)) # E: Union[numpy.number[Any], numpy.ndarray] -reveal_type(np.mean(B, axis=0)) # E: Union[numpy.number[Any], numpy.ndarray] -reveal_type(np.mean(A, keepdims=True)) # E: Union[numpy.number[Any], numpy.ndarray] -reveal_type(np.mean(B, keepdims=True)) # E: Union[numpy.number[Any], numpy.ndarray] -reveal_type(np.mean(b, out=d)) # E: numpy.ndarray -reveal_type(np.mean(B, out=d)) # E: numpy.ndarray - -reveal_type(np.std(a)) # E: numpy.number[Any] -reveal_type(np.std(b)) # E: numpy.number[Any] -reveal_type(np.std(c)) # E: numpy.number[Any] -reveal_type(np.std(A)) # E: numpy.number[Any] -reveal_type(np.std(B)) # E: numpy.number[Any] -reveal_type(np.std(A, axis=0)) # E: Union[numpy.number[Any], numpy.ndarray] -reveal_type(np.std(B, axis=0)) # E: Union[numpy.number[Any], numpy.ndarray] -reveal_type(np.std(A, keepdims=True)) # E: Union[numpy.number[Any], numpy.ndarray] -reveal_type(np.std(B, keepdims=True)) # E: Union[numpy.number[Any], numpy.ndarray] -reveal_type(np.std(b, out=d)) # E: numpy.ndarray -reveal_type(np.std(B, out=d)) # E: numpy.ndarray - -reveal_type(np.var(a)) # E: numpy.number[Any] -reveal_type(np.var(b)) # E: numpy.number[Any] -reveal_type(np.var(c)) # E: numpy.number[Any] -reveal_type(np.var(A)) # E: numpy.number[Any] -reveal_type(np.var(B)) # E: numpy.number[Any] -reveal_type(np.var(A, axis=0)) # E: Union[numpy.number[Any], numpy.ndarray] -reveal_type(np.var(B, axis=0)) # E: Union[numpy.number[Any], numpy.ndarray] -reveal_type(np.var(A, keepdims=True)) # E: Union[numpy.number[Any], numpy.ndarray] -reveal_type(np.var(B, keepdims=True)) # E: Union[numpy.number[Any], numpy.ndarray] -reveal_type(np.var(b, out=d)) # E: numpy.ndarray -reveal_type(np.var(B, out=d)) # E: numpy.ndarray +reveal_type(np.around(a)) # E: Any +reveal_type(np.around(b)) # E: Any +reveal_type(np.around(c)) # E: Any +reveal_type(np.around(A)) # E: Any +reveal_type(np.around(B)) # E: Any + +reveal_type(np.mean(a)) # E: Any +reveal_type(np.mean(b)) # E: Any +reveal_type(np.mean(c)) # E: Any +reveal_type(np.mean(A)) # E: Any +reveal_type(np.mean(B)) # E: Any +reveal_type(np.mean(A, axis=0)) # E: Any +reveal_type(np.mean(B, axis=0)) # E: Any +reveal_type(np.mean(A, keepdims=True)) # E: Any +reveal_type(np.mean(B, keepdims=True)) # E: Any +reveal_type(np.mean(b, out=d)) # E: Any +reveal_type(np.mean(B, out=d)) # E: Any + +reveal_type(np.std(a)) # E: Any +reveal_type(np.std(b)) # E: Any +reveal_type(np.std(c)) # E: Any +reveal_type(np.std(A)) # E: Any +reveal_type(np.std(B)) # E: Any +reveal_type(np.std(A, axis=0)) # E: Any +reveal_type(np.std(B, axis=0)) # E: Any +reveal_type(np.std(A, keepdims=True)) # E: Any +reveal_type(np.std(B, keepdims=True)) # E: Any +reveal_type(np.std(b, out=d)) # E: Any +reveal_type(np.std(B, out=d)) # E: Any + +reveal_type(np.var(a)) # E: Any +reveal_type(np.var(b)) # E: Any +reveal_type(np.var(c)) # E: Any +reveal_type(np.var(A)) # E: Any +reveal_type(np.var(B)) # E: Any +reveal_type(np.var(A, axis=0)) # E: Any +reveal_type(np.var(B, axis=0)) # E: Any +reveal_type(np.var(A, keepdims=True)) # E: Any +reveal_type(np.var(B, keepdims=True)) # E: Any +reveal_type(np.var(b, out=d)) # E: Any +reveal_type(np.var(B, out=d)) # E: Any From c753d15674212f0577c9b8bb98c797b076eecf23 Mon Sep 17 00:00:00 2001 From: Bas van Beek Date: Wed, 21 Apr 2021 18:06:36 +0200 Subject: [PATCH 16/33] MAINT: Remove unsafe unions from `np.core.function_base` --- numpy/core/function_base.pyi | 6 ++++-- numpy/typing/tests/data/reveal/array_constructors.py | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/numpy/core/function_base.pyi b/numpy/core/function_base.pyi index 1490bed4aff3..573dc219378b 100644 --- a/numpy/core/function_base.pyi +++ b/numpy/core/function_base.pyi @@ -1,7 +1,7 @@ import sys from typing import overload, Tuple, Union, Sequence, Any -from numpy import ndarray, inexact +from numpy import ndarray from numpy.typing import ArrayLike, DTypeLike, _SupportsArray, _NumberLike if sys.version_info >= (3, 8): @@ -36,7 +36,8 @@ def linspace( retstep: Literal[True] = ..., dtype: DTypeLike = ..., axis: SupportsIndex = ..., -) -> Tuple[ndarray, inexact]: ... +) -> Tuple[ndarray, Any]: ... + def logspace( start: _ArrayLikeNumber, stop: _ArrayLikeNumber, @@ -46,6 +47,7 @@ def logspace( dtype: DTypeLike = ..., axis: SupportsIndex = ..., ) -> ndarray: ... + def geomspace( start: _ArrayLikeNumber, stop: _ArrayLikeNumber, diff --git a/numpy/typing/tests/data/reveal/array_constructors.py b/numpy/typing/tests/data/reveal/array_constructors.py index 106174736085..c4c162bb2a4b 100644 --- a/numpy/typing/tests/data/reveal/array_constructors.py +++ b/numpy/typing/tests/data/reveal/array_constructors.py @@ -41,7 +41,7 @@ def func(i: int, j: int, **kwargs: Any) -> SubClass: ... reveal_type(np.require(C)) # E: ndarray reveal_type(np.linspace(0, 10)) # E: numpy.ndarray -reveal_type(np.linspace(0, 10, retstep=True)) # E: Tuple[numpy.ndarray, numpy.inexact[Any]] +reveal_type(np.linspace(0, 10, retstep=True)) # E: Tuple[numpy.ndarray, Any] reveal_type(np.logspace(0, 10)) # E: numpy.ndarray reveal_type(np.geomspace(1, 10)) # E: numpy.ndarray From 76865f9bb54bbc5dfda4cb44c044efdeb313b065 Mon Sep 17 00:00:00 2001 From: Bas van Beek Date: Wed, 21 Apr 2021 18:19:12 +0200 Subject: [PATCH 17/33] MAINT: Remove unsafe unions from `np.core.numeric` --- numpy/core/numeric.pyi | 72 ++++++++++++++++++++--- numpy/typing/tests/data/reveal/numeric.py | 10 ++-- 2 files changed, 68 insertions(+), 14 deletions(-) diff --git a/numpy/core/numeric.pyi b/numpy/core/numeric.pyi index d91cb31c2031..6b9ef4b20b98 100644 --- a/numpy/core/numeric.pyi +++ b/numpy/core/numeric.pyi @@ -41,6 +41,7 @@ def zeros_like( subok: bool = ..., shape: Optional[_ShapeLike] = ..., ) -> ndarray: ... + def ones( shape: _ShapeLike, dtype: DTypeLike = ..., @@ -48,6 +49,7 @@ def ones( *, like: ArrayLike = ..., ) -> ndarray: ... + @overload def ones_like( a: _ArrayType, @@ -64,6 +66,7 @@ def ones_like( subok: bool = ..., shape: Optional[_ShapeLike] = ..., ) -> ndarray: ... + @overload def empty_like( a: _ArrayType, @@ -80,6 +83,7 @@ def empty_like( subok: bool = ..., shape: Optional[_ShapeLike] = ..., ) -> ndarray: ... + def full( shape: _ShapeLike, fill_value: Any, @@ -88,6 +92,7 @@ def full( *, like: ArrayLike = ..., ) -> ndarray: ... + @overload def full_like( a: _ArrayType, @@ -106,39 +111,73 @@ def full_like( subok: bool = ..., shape: Optional[_ShapeLike] = ..., ) -> ndarray: ... + @overload def count_nonzero( - a: ArrayLike, axis: None = ..., *, keepdims: Literal[False] = ... + a: ArrayLike, + axis: None = ..., + *, + keepdims: Literal[False] = ..., ) -> int: ... @overload def count_nonzero( - a: ArrayLike, axis: _ShapeLike = ..., *, keepdims: bool = ... -) -> Union[signedinteger[Any], ndarray]: ... # TODO: np.intp + a: ArrayLike, + axis: _ShapeLike = ..., + *, + keepdims: bool = ..., +) -> Any: ... # TODO: np.intp or ndarray[np.intp] + def isfortran(a: Union[ndarray, generic]) -> bool: ... + def argwhere(a: ArrayLike) -> ndarray: ... + def flatnonzero(a: ArrayLike) -> ndarray: ... -def correlate(a: ArrayLike, v: ArrayLike, mode: _CorrelateMode = ...) -> ndarray: ... -def convolve(a: ArrayLike, v: ArrayLike, mode: _CorrelateMode = ...) -> ndarray: ... + +def correlate( + a: ArrayLike, + v: ArrayLike, + mode: _CorrelateMode = ..., +) -> ndarray: ... + +def convolve( + a: ArrayLike, + v: ArrayLike, + mode: _CorrelateMode = ..., +) -> ndarray: ... + @overload -def outer(a: ArrayLike, b: ArrayLike, out: None = ...) -> ndarray: ... +def outer( + a: ArrayLike, + b: ArrayLike, + out: None = ..., +) -> ndarray: ... @overload -def outer(a: ArrayLike, b: ArrayLike, out: _ArrayType = ...) -> _ArrayType: ... +def outer( + a: ArrayLike, + b: ArrayLike, + out: _ArrayType = ..., +) -> _ArrayType: ... + def tensordot( a: ArrayLike, b: ArrayLike, axes: Union[int, Tuple[_ShapeLike, _ShapeLike]] = ..., ) -> ndarray: ... + def roll( a: ArrayLike, shift: _ShapeLike, axis: Optional[_ShapeLike] = ..., ) -> ndarray: ... + def rollaxis(a: ndarray, axis: int, start: int = ...) -> ndarray: ... + def moveaxis( a: ndarray, source: _ShapeLike, destination: _ShapeLike, ) -> ndarray: ... + def cross( a: ArrayLike, b: ArrayLike, @@ -147,6 +186,7 @@ def cross( axisc: int = ..., axis: Optional[int] = ..., ) -> ndarray: ... + @overload def indices( dimensions: Sequence[int], @@ -159,6 +199,7 @@ def indices( dtype: DTypeLike = ..., sparse: Literal[True] = ..., ) -> Tuple[ndarray, ...]: ... + def fromfunction( function: Callable[..., _T], shape: Sequence[int], @@ -167,10 +208,20 @@ def fromfunction( like: ArrayLike = ..., **kwargs: Any, ) -> _T: ... + def isscalar(element: Any) -> bool: ... + def binary_repr(num: int, width: Optional[int] = ...) -> str: ... + def base_repr(number: int, base: int = ..., padding: int = ...) -> str: ... -def identity(n: int, dtype: DTypeLike = ..., *, like: ArrayLike = ...) -> ndarray: ... + +def identity( + n: int, + dtype: DTypeLike = ..., + *, + like: ArrayLike = ..., +) -> ndarray: ... + def allclose( a: ArrayLike, b: ArrayLike, @@ -178,12 +229,15 @@ def allclose( atol: float = ..., equal_nan: bool = ..., ) -> bool: ... + def isclose( a: ArrayLike, b: ArrayLike, rtol: float = ..., atol: float = ..., equal_nan: bool = ..., -) -> Union[bool_, ndarray]: ... +) -> Any: ... + def array_equal(a1: ArrayLike, a2: ArrayLike) -> bool: ... + def array_equiv(a1: ArrayLike, a2: ArrayLike) -> bool: ... diff --git a/numpy/typing/tests/data/reveal/numeric.py b/numpy/typing/tests/data/reveal/numeric.py index 5cbfa4ac765c..a3671cef95ce 100644 --- a/numpy/typing/tests/data/reveal/numeric.py +++ b/numpy/typing/tests/data/reveal/numeric.py @@ -20,8 +20,8 @@ class SubClass(np.ndarray): reveal_type(np.count_nonzero(i8)) # E: int reveal_type(np.count_nonzero(A)) # E: int reveal_type(np.count_nonzero(B)) # E: int -reveal_type(np.count_nonzero(A, keepdims=True)) # E: Union[numpy.signedinteger[Any], numpy.ndarray] -reveal_type(np.count_nonzero(A, axis=0)) # E: Union[numpy.signedinteger[Any], numpy.ndarray] +reveal_type(np.count_nonzero(A, keepdims=True)) # E: Any +reveal_type(np.count_nonzero(A, axis=0)) # E: Any reveal_type(np.isfortran(i8)) # E: bool reveal_type(np.isfortran(A)) # E: bool @@ -76,9 +76,9 @@ class SubClass(np.ndarray): reveal_type(np.allclose(B, A)) # E: bool reveal_type(np.allclose(A, A)) # E: bool -reveal_type(np.isclose(i8, A)) # E: Union[numpy.bool_, numpy.ndarray] -reveal_type(np.isclose(B, A)) # E: Union[numpy.bool_, numpy.ndarray] -reveal_type(np.isclose(A, A)) # E: Union[numpy.bool_, numpy.ndarray] +reveal_type(np.isclose(i8, A)) # E: Any +reveal_type(np.isclose(B, A)) # E: Any +reveal_type(np.isclose(A, A)) # E: Any reveal_type(np.array_equal(i8, A)) # E: bool reveal_type(np.array_equal(B, A)) # E: bool From ad2a144a4bcef20eabff770b75c9aa165177feea Mon Sep 17 00:00:00 2001 From: Bas van Beek Date: Wed, 21 Apr 2021 19:00:56 +0200 Subject: [PATCH 18/33] MAINT: Remove unsafe unions from `np.typing._callable` --- numpy/typing/_callable.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/numpy/typing/_callable.py b/numpy/typing/_callable.py index 91b7a4ec21c0..ad38028e1952 100644 --- a/numpy/typing/_callable.py +++ b/numpy/typing/_callable.py @@ -156,7 +156,7 @@ def __call__(self, __other: bool) -> unsignedinteger[_NBit_co]: ... @overload def __call__( self, __other: Union[int, signedinteger[Any]] - ) -> Union[signedinteger[Any], float64]: ... + ) -> Any: ... @overload def __call__(self, __other: float) -> float64: ... @overload @@ -184,7 +184,7 @@ def __call__(self, __other: bool) -> unsignedinteger[_NBit_co]: ... @overload def __call__( self, __other: Union[int, signedinteger[Any]] - ) -> Union[signedinteger[Any], float64]: ... + ) -> Any: ... @overload def __call__(self, __other: float) -> float64: ... @overload @@ -198,7 +198,7 @@ def __call__(self, __other: bool) -> _2Tuple[signedinteger[_NBit_co]]: ... @overload def __call__( self, __other: Union[int, signedinteger[Any]] - ) -> Union[_2Tuple[signedinteger[Any]], _2Tuple[float64]]: ... + ) -> _2Tuple[Any]: ... @overload def __call__(self, __other: float) -> _2Tuple[float64]: ... @overload From 3b3dbdda2de4d6193dd4ab299067f20fb47515f2 Mon Sep 17 00:00:00 2001 From: Bas van Beek Date: Wed, 21 Apr 2021 19:00:30 +0200 Subject: [PATCH 19/33] MAINT: Remove unsafe unions from `np` --- numpy/__init__.pyi | 206 +++++++++--------- numpy/typing/tests/data/reveal/arithmetic.py | 28 +-- .../typing/tests/data/reveal/ndarray_misc.py | 90 ++++---- 3 files changed, 163 insertions(+), 161 deletions(-) diff --git a/numpy/__init__.pyi b/numpy/__init__.pyi index 9435c27f30ae..5146a11d5eb5 100644 --- a/numpy/__init__.pyi +++ b/numpy/__init__.pyi @@ -1048,14 +1048,21 @@ class _ArrayOrScalarCommon: def __array_wrap__(array, context=...): ... def __setstate__(self, __state): ... # a `bool_` is returned when `keepdims=True` and `self` is a 0d array + @overload def all( - self, axis: None = ..., out: None = ..., keepdims: Literal[False] = ... + self, + axis: None = ..., + out: None = ..., + keepdims: Literal[False] = ..., ) -> bool_: ... @overload def all( - self, axis: Optional[_ShapeLike] = ..., out: None = ..., keepdims: bool = ... - ) -> Union[bool_, ndarray]: ... + self, + axis: Optional[_ShapeLike] = ..., + out: None = ..., + keepdims: bool = ..., + ) -> Any: ... @overload def all( self, @@ -1063,14 +1070,21 @@ class _ArrayOrScalarCommon: out: _NdArraySubClass = ..., keepdims: bool = ..., ) -> _NdArraySubClass: ... + @overload def any( - self, axis: None = ..., out: None = ..., keepdims: Literal[False] = ... + self, + axis: None = ..., + out: None = ..., + keepdims: Literal[False] = ..., ) -> bool_: ... @overload def any( - self, axis: Optional[_ShapeLike] = ..., out: None = ..., keepdims: bool = ... - ) -> Union[bool_, ndarray]: ... + self, + axis: Optional[_ShapeLike] = ..., + out: None = ..., + keepdims: bool = ..., + ) -> Any: ... @overload def any( self, @@ -1078,40 +1092,67 @@ class _ArrayOrScalarCommon: out: _NdArraySubClass = ..., keepdims: bool = ..., ) -> _NdArraySubClass: ... + @overload - def argmax(self, axis: None = ..., out: None = ...) -> signedinteger: ... + def argmax( + self, + axis: None = ..., + out: None = ..., + ) -> signedinteger[Any]: ... @overload def argmax( - self, axis: _ShapeLike = ..., out: None = ... - ) -> Union[signedinteger, ndarray]: ... + self, + axis: _ShapeLike = ..., + out: None = ..., + ) -> Any: ... @overload def argmax( - self, axis: Optional[_ShapeLike] = ..., out: _NdArraySubClass = ... + self, + axis: Optional[_ShapeLike] = ..., + out: _NdArraySubClass = ..., ) -> _NdArraySubClass: ... + @overload - def argmin(self, axis: None = ..., out: None = ...) -> signedinteger: ... + def argmin( + self, + axis: None = ..., + out: None = ..., + ) -> signedinteger[Any]: ... @overload def argmin( - self, axis: _ShapeLike = ..., out: None = ... - ) -> Union[signedinteger, ndarray]: ... + self, + axis: _ShapeLike = ..., + out: None = ..., + ) -> Any: ... @overload def argmin( - self, axis: Optional[_ShapeLike] = ..., out: _NdArraySubClass = ... + self, + axis: Optional[_ShapeLike] = ..., + out: _NdArraySubClass = ..., ) -> _NdArraySubClass: ... + def argsort( self, axis: Optional[SupportsIndex] = ..., kind: Optional[_SortKind] = ..., order: Union[None, str, Sequence[str]] = ..., ) -> ndarray: ... + @overload def choose( - self, choices: ArrayLike, out: None = ..., mode: _ModeKind = ..., + self, + choices: ArrayLike, + out: None = ..., + mode: _ModeKind = ..., ) -> ndarray: ... @overload def choose( - self, choices: ArrayLike, out: _NdArraySubClass = ..., mode: _ModeKind = ..., + self, + choices: ArrayLike, + out: _NdArraySubClass = ..., + mode: _ModeKind = ..., ) -> _NdArraySubClass: ... + @overload def clip( self, @@ -1119,7 +1160,7 @@ class _ArrayOrScalarCommon: max: Optional[ArrayLike] = ..., out: None = ..., **kwargs: Any, - ) -> Union[number, ndarray]: ... + ) -> Any: ... @overload def clip( self, @@ -1127,7 +1168,7 @@ class _ArrayOrScalarCommon: max: ArrayLike = ..., out: None = ..., **kwargs: Any, - ) -> Union[number, ndarray]: ... + ) -> Any: ... @overload def clip( self, @@ -1144,6 +1185,7 @@ class _ArrayOrScalarCommon: out: _NdArraySubClass = ..., **kwargs: Any, ) -> _NdArraySubClass: ... + @overload def compress( self, @@ -1158,8 +1200,11 @@ class _ArrayOrScalarCommon: axis: Optional[SupportsIndex] = ..., out: _NdArraySubClass = ..., ) -> _NdArraySubClass: ... + def conj(self: _ArraySelf) -> _ArraySelf: ... + def conjugate(self: _ArraySelf) -> _ArraySelf: ... + @overload def cumprod( self, @@ -1174,6 +1219,7 @@ class _ArrayOrScalarCommon: dtype: DTypeLike = ..., out: _NdArraySubClass = ..., ) -> _NdArraySubClass: ... + @overload def cumsum( self, @@ -1188,15 +1234,7 @@ class _ArrayOrScalarCommon: dtype: DTypeLike = ..., out: _NdArraySubClass = ..., ) -> _NdArraySubClass: ... - @overload - def max( - self, - axis: None = ..., - out: None = ..., - keepdims: Literal[False] = ..., - initial: _NumberLike = ..., - where: _ArrayLikeBool = ..., - ) -> number: ... + @overload def max( self, @@ -1205,7 +1243,7 @@ class _ArrayOrScalarCommon: keepdims: bool = ..., initial: _NumberLike = ..., where: _ArrayLikeBool = ..., - ) -> Union[number, ndarray]: ... + ) -> Any: ... @overload def max( self, @@ -1215,14 +1253,7 @@ class _ArrayOrScalarCommon: initial: _NumberLike = ..., where: _ArrayLikeBool = ..., ) -> _NdArraySubClass: ... - @overload - def mean( - self, - axis: None = ..., - dtype: DTypeLike = ..., - out: None = ..., - keepdims: Literal[False] = ..., - ) -> number: ... + @overload def mean( self, @@ -1230,7 +1261,7 @@ class _ArrayOrScalarCommon: dtype: DTypeLike = ..., out: None = ..., keepdims: bool = ..., - ) -> Union[number, ndarray]: ... + ) -> Any: ... @overload def mean( self, @@ -1239,15 +1270,7 @@ class _ArrayOrScalarCommon: out: _NdArraySubClass = ..., keepdims: bool = ..., ) -> _NdArraySubClass: ... - @overload - def min( - self, - axis: None = ..., - out: None = ..., - keepdims: Literal[False] = ..., - initial: _NumberLike = ..., - where: _ArrayLikeBool = ..., - ) -> number: ... + @overload def min( self, @@ -1256,7 +1279,7 @@ class _ArrayOrScalarCommon: keepdims: bool = ..., initial: _NumberLike = ..., where: _ArrayLikeBool = ..., - ) -> Union[number, ndarray]: ... + ) -> Any: ... @overload def min( self, @@ -1266,17 +1289,12 @@ class _ArrayOrScalarCommon: initial: _NumberLike = ..., where: _ArrayLikeBool = ..., ) -> _NdArraySubClass: ... - def newbyteorder(self: _ArraySelf, __new_order: _ByteOrder = ...) -> _ArraySelf: ... - @overload - def prod( - self, - axis: None = ..., - dtype: DTypeLike = ..., - out: None = ..., - keepdims: Literal[False] = ..., - initial: _NumberLike = ..., - where: _ArrayLikeBool = ..., - ) -> number: ... + + def newbyteorder( + self: _ArraySelf, + __new_order: _ByteOrder = ..., + ) -> _ArraySelf: ... + @overload def prod( self, @@ -1286,7 +1304,7 @@ class _ArrayOrScalarCommon: keepdims: bool = ..., initial: _NumberLike = ..., where: _ArrayLikeBool = ..., - ) -> Union[number, ndarray]: ... + ) -> Any: ... @overload def prod( self, @@ -1297,14 +1315,14 @@ class _ArrayOrScalarCommon: initial: _NumberLike = ..., where: _ArrayLikeBool = ..., ) -> _NdArraySubClass: ... + @overload def ptp( - self, axis: None = ..., out: None = ..., keepdims: Literal[False] = ..., - ) -> number: ... - @overload - def ptp( - self, axis: Optional[_ShapeLike] = ..., out: None = ..., keepdims: bool = ..., - ) -> Union[number, ndarray]: ... + self, + axis: Optional[_ShapeLike] = ..., + out: None = ..., + keepdims: bool = ..., + ) -> Any: ... @overload def ptp( self, @@ -1312,26 +1330,26 @@ class _ArrayOrScalarCommon: out: _NdArraySubClass = ..., keepdims: bool = ..., ) -> _NdArraySubClass: ... + def repeat( - self, repeats: _ArrayLikeIntOrBool, axis: Optional[SupportsIndex] = ... + self, + repeats: _ArrayLikeIntOrBool, + axis: Optional[SupportsIndex] = ..., ) -> ndarray: ... + @overload def round( - self: _ArraySelf, decimals: SupportsIndex = ..., out: None = ... + self: _ArraySelf, + decimals: SupportsIndex = ..., + out: None = ..., ) -> _ArraySelf: ... @overload def round( - self, decimals: SupportsIndex = ..., out: _NdArraySubClass = ... - ) -> _NdArraySubClass: ... - @overload - def std( self, - axis: None = ..., - dtype: DTypeLike = ..., - out: None = ..., - ddof: int = ..., - keepdims: Literal[False] = ..., - ) -> number: ... + decimals: SupportsIndex = ..., + out: _NdArraySubClass = ..., + ) -> _NdArraySubClass: ... + @overload def std( self, @@ -1340,7 +1358,7 @@ class _ArrayOrScalarCommon: out: None = ..., ddof: int = ..., keepdims: bool = ..., - ) -> Union[number, ndarray]: ... + ) -> Any: ... @overload def std( self, @@ -1350,16 +1368,7 @@ class _ArrayOrScalarCommon: ddof: int = ..., keepdims: bool = ..., ) -> _NdArraySubClass: ... - @overload - def sum( - self, - axis: None = ..., - dtype: DTypeLike = ..., - out: None = ..., - keepdims: Literal[False] = ..., - initial: _NumberLike = ..., - where: _ArrayLikeBool = ..., - ) -> number: ... + @overload def sum( self, @@ -1369,7 +1378,7 @@ class _ArrayOrScalarCommon: keepdims: bool = ..., initial: _NumberLike = ..., where: _ArrayLikeBool = ..., - ) -> Union[number, ndarray]: ... + ) -> Any: ... @overload def sum( self, @@ -1380,6 +1389,7 @@ class _ArrayOrScalarCommon: initial: _NumberLike = ..., where: _ArrayLikeBool = ..., ) -> _NdArraySubClass: ... + @overload def take( self, @@ -1387,7 +1397,7 @@ class _ArrayOrScalarCommon: axis: Optional[SupportsIndex] = ..., out: None = ..., mode: _ModeKind = ..., - ) -> generic: ... + ) -> Any: ... @overload def take( self, @@ -1404,15 +1414,7 @@ class _ArrayOrScalarCommon: out: _NdArraySubClass = ..., mode: _ModeKind = ..., ) -> _NdArraySubClass: ... - @overload - def var( - self, - axis: None = ..., - dtype: DTypeLike = ..., - out: None = ..., - ddof: int = ..., - keepdims: Literal[False] = ..., - ) -> number: ... + @overload def var( self, @@ -1421,7 +1423,7 @@ class _ArrayOrScalarCommon: out: None = ..., ddof: int = ..., keepdims: bool = ..., - ) -> Union[number, ndarray]: ... + ) -> Any: ... @overload def var( self, @@ -1512,7 +1514,7 @@ class ndarray(_ArrayOrScalarCommon, Iterable, Sized, Container): axis2: SupportsIndex = ..., ) -> _ArraySelf: ... @overload - def dot(self, b: ArrayLike, out: None = ...) -> Union[number, ndarray]: ... + def dot(self, b: ArrayLike, out: None = ...) -> Any: ... @overload def dot(self, b: ArrayLike, out: _NdArraySubClass = ...) -> _NdArraySubClass: ... # `nonzero()` is deprecated for 0d arrays/generics @@ -1552,7 +1554,7 @@ class ndarray(_ArrayOrScalarCommon, Iterable, Sized, Container): axis2: SupportsIndex = ..., dtype: DTypeLike = ..., out: None = ..., - ) -> Union[number, ndarray]: ... + ) -> Any: ... @overload def trace( self, # >= 2D array diff --git a/numpy/typing/tests/data/reveal/arithmetic.py b/numpy/typing/tests/data/reveal/arithmetic.py index 20310e691647..7d93893d4009 100644 --- a/numpy/typing/tests/data/reveal/arithmetic.py +++ b/numpy/typing/tests/data/reveal/arithmetic.py @@ -217,9 +217,9 @@ # Int reveal_type(i8 + i8) # E: numpy.signedinteger[numpy.typing._64Bit] -reveal_type(i8 + u8) # E: Union[numpy.signedinteger[Any], numpy.floating[numpy.typing._64Bit]] +reveal_type(i8 + u8) # E: Any reveal_type(i8 + i4) # E: numpy.signedinteger[numpy.typing._64Bit] -reveal_type(i8 + u4) # E: Union[numpy.signedinteger[Any], numpy.floating[numpy.typing._64Bit]] +reveal_type(i8 + u4) # E: Any reveal_type(i8 + b_) # E: numpy.signedinteger[numpy.typing._64Bit] reveal_type(i8 + b) # E: numpy.signedinteger[numpy.typing._64Bit] reveal_type(i8 + c) # E: numpy.complexfloating[numpy.typing._64Bit, numpy.typing._64Bit] @@ -228,19 +228,19 @@ reveal_type(i8 + AR) # E: Any reveal_type(u8 + u8) # E: numpy.unsignedinteger[numpy.typing._64Bit] -reveal_type(u8 + i4) # E: Union[numpy.signedinteger[Any], numpy.floating[numpy.typing._64Bit]] +reveal_type(u8 + i4) # E: Any reveal_type(u8 + u4) # E: numpy.unsignedinteger[numpy.typing._64Bit] reveal_type(u8 + b_) # E: numpy.unsignedinteger[numpy.typing._64Bit] reveal_type(u8 + b) # E: numpy.unsignedinteger[numpy.typing._64Bit] reveal_type(u8 + c) # E: numpy.complexfloating[numpy.typing._64Bit, numpy.typing._64Bit] reveal_type(u8 + f) # E: numpy.floating[numpy.typing._64Bit] -reveal_type(u8 + i) # E: Union[numpy.signedinteger[Any], numpy.floating[numpy.typing._64Bit]] +reveal_type(u8 + i) # E: Any reveal_type(u8 + AR) # E: Any reveal_type(i8 + i8) # E: numpy.signedinteger[numpy.typing._64Bit] -reveal_type(u8 + i8) # E: Union[numpy.signedinteger[Any], numpy.floating[numpy.typing._64Bit]] +reveal_type(u8 + i8) # E: Any reveal_type(i4 + i8) # E: numpy.signedinteger[numpy.typing._64Bit] -reveal_type(u4 + i8) # E: Union[numpy.signedinteger[Any], numpy.floating[numpy.typing._64Bit]] +reveal_type(u4 + i8) # E: Any reveal_type(b_ + i8) # E: numpy.signedinteger[numpy.typing._64Bit] reveal_type(b + i8) # E: numpy.signedinteger[numpy.typing._64Bit] reveal_type(c + i8) # E: numpy.complexfloating[numpy.typing._64Bit, numpy.typing._64Bit] @@ -249,13 +249,13 @@ reveal_type(AR + i8) # E: Any reveal_type(u8 + u8) # E: numpy.unsignedinteger[numpy.typing._64Bit] -reveal_type(i4 + u8) # E: Union[numpy.signedinteger[Any], numpy.floating[numpy.typing._64Bit]] +reveal_type(i4 + u8) # E: Any reveal_type(u4 + u8) # E: numpy.unsignedinteger[numpy.typing._64Bit] reveal_type(b_ + u8) # E: numpy.unsignedinteger[numpy.typing._64Bit] reveal_type(b + u8) # E: numpy.unsignedinteger[numpy.typing._64Bit] reveal_type(c + u8) # E: numpy.complexfloating[numpy.typing._64Bit, numpy.typing._64Bit] reveal_type(f + u8) # E: numpy.floating[numpy.typing._64Bit] -reveal_type(i + u8) # E: Union[numpy.signedinteger[Any], numpy.floating[numpy.typing._64Bit]] +reveal_type(i + u8) # E: Any reveal_type(AR + u8) # E: Any reveal_type(i4 + i8) # E: numpy.signedinteger[numpy.typing._64Bit] @@ -265,11 +265,11 @@ reveal_type(i4 + b) # E: numpy.signedinteger[numpy.typing._32Bit] reveal_type(i4 + AR) # E: Any -reveal_type(u4 + i8) # E: Union[numpy.signedinteger[Any], numpy.floating[numpy.typing._64Bit]] -reveal_type(u4 + i4) # E: Union[numpy.signedinteger[Any], numpy.floating[numpy.typing._64Bit]] +reveal_type(u4 + i8) # E: Any +reveal_type(u4 + i4) # E: Any reveal_type(u4 + u8) # E: numpy.unsignedinteger[numpy.typing._64Bit] reveal_type(u4 + u4) # E: numpy.unsignedinteger[numpy.typing._32Bit] -reveal_type(u4 + i) # E: Union[numpy.signedinteger[Any], numpy.floating[numpy.typing._64Bit]] +reveal_type(u4 + i) # E: Any reveal_type(u4 + b_) # E: numpy.unsignedinteger[numpy.typing._32Bit] reveal_type(u4 + b) # E: numpy.unsignedinteger[numpy.typing._32Bit] reveal_type(u4 + AR) # E: Any @@ -281,11 +281,11 @@ reveal_type(b + i4) # E: numpy.signedinteger[numpy.typing._32Bit] reveal_type(AR + i4) # E: Any -reveal_type(i8 + u4) # E: Union[numpy.signedinteger[Any], numpy.floating[numpy.typing._64Bit]] -reveal_type(i4 + u4) # E: Union[numpy.signedinteger[Any], numpy.floating[numpy.typing._64Bit]] +reveal_type(i8 + u4) # E: Any +reveal_type(i4 + u4) # E: Any reveal_type(u8 + u4) # E: numpy.unsignedinteger[numpy.typing._64Bit] reveal_type(u4 + u4) # E: numpy.unsignedinteger[numpy.typing._32Bit] reveal_type(b_ + u4) # E: numpy.unsignedinteger[numpy.typing._32Bit] reveal_type(b + u4) # E: numpy.unsignedinteger[numpy.typing._32Bit] -reveal_type(i + u4) # E: Union[numpy.signedinteger[Any], numpy.floating[numpy.typing._64Bit]] +reveal_type(i + u4) # E: Any reveal_type(AR + u4) # E: Any diff --git a/numpy/typing/tests/data/reveal/ndarray_misc.py b/numpy/typing/tests/data/reveal/ndarray_misc.py index 826c8aaa6d12..80e1c484ed76 100644 --- a/numpy/typing/tests/data/reveal/ndarray_misc.py +++ b/numpy/typing/tests/data/reveal/ndarray_misc.py @@ -16,24 +16,24 @@ class SubClass(np.ndarray): ... reveal_type(f8.all()) # E: numpy.bool_ reveal_type(A.all()) # E: numpy.bool_ -reveal_type(A.all(axis=0)) # E: Union[numpy.bool_, numpy.ndarray] -reveal_type(A.all(keepdims=True)) # E: Union[numpy.bool_, numpy.ndarray] +reveal_type(A.all(axis=0)) # E: Any +reveal_type(A.all(keepdims=True)) # E: Any reveal_type(A.all(out=B)) # E: SubClass reveal_type(f8.any()) # E: numpy.bool_ reveal_type(A.any()) # E: numpy.bool_ -reveal_type(A.any(axis=0)) # E: Union[numpy.bool_, numpy.ndarray] -reveal_type(A.any(keepdims=True)) # E: Union[numpy.bool_, numpy.ndarray] +reveal_type(A.any(axis=0)) # E: Any +reveal_type(A.any(keepdims=True)) # E: Any reveal_type(A.any(out=B)) # E: SubClass reveal_type(f8.argmax()) # E: numpy.signedinteger[Any] reveal_type(A.argmax()) # E: numpy.signedinteger[Any] -reveal_type(A.argmax(axis=0)) # E: Union[numpy.signedinteger[Any], numpy.ndarray] +reveal_type(A.argmax(axis=0)) # E: Any reveal_type(A.argmax(out=B)) # E: SubClass reveal_type(f8.argmin()) # E: numpy.signedinteger[Any] reveal_type(A.argmin()) # E: numpy.signedinteger[Any] -reveal_type(A.argmin(axis=0)) # E: Union[numpy.signedinteger[Any], numpy.ndarray] +reveal_type(A.argmin(axis=0)) # E: Any reveal_type(A.argmin(out=B)) # E: SubClass reveal_type(f8.argsort()) # E: numpy.ndarray @@ -43,9 +43,9 @@ class SubClass(np.ndarray): ... reveal_type(A.choose([0])) # E: numpy.ndarray reveal_type(A.choose([0], out=B)) # E: SubClass -reveal_type(f8.clip(1)) # E: Union[numpy.number[Any], numpy.ndarray] -reveal_type(A.clip(1)) # E: Union[numpy.number[Any], numpy.ndarray] -reveal_type(A.clip(None, 1)) # E: Union[numpy.number[Any], numpy.ndarray] +reveal_type(f8.clip(1)) # E: Any +reveal_type(A.clip(1)) # E: Any +reveal_type(A.clip(None, 1)) # E: Any reveal_type(A.clip(1, out=B)) # E: SubClass reveal_type(A.clip(None, 1, out=B)) # E: SubClass @@ -69,38 +69,38 @@ class SubClass(np.ndarray): ... reveal_type(A.cumsum()) # E: numpy.ndarray reveal_type(A.cumsum(out=B)) # E: SubClass -reveal_type(f8.max()) # E: numpy.number[Any] -reveal_type(A.max()) # E: numpy.number[Any] -reveal_type(A.max(axis=0)) # E: Union[numpy.number[Any], numpy.ndarray] -reveal_type(A.max(keepdims=True)) # E: Union[numpy.number[Any], numpy.ndarray] +reveal_type(f8.max()) # E: Any +reveal_type(A.max()) # E: Any +reveal_type(A.max(axis=0)) # E: Any +reveal_type(A.max(keepdims=True)) # E: Any reveal_type(A.max(out=B)) # E: SubClass -reveal_type(f8.mean()) # E: numpy.number[Any] -reveal_type(A.mean()) # E: numpy.number[Any] -reveal_type(A.mean(axis=0)) # E: Union[numpy.number[Any], numpy.ndarray] -reveal_type(A.mean(keepdims=True)) # E: Union[numpy.number[Any], numpy.ndarray] +reveal_type(f8.mean()) # E: Any +reveal_type(A.mean()) # E: Any +reveal_type(A.mean(axis=0)) # E: Any +reveal_type(A.mean(keepdims=True)) # E: Any reveal_type(A.mean(out=B)) # E: SubClass -reveal_type(f8.min()) # E: numpy.number[Any] -reveal_type(A.min()) # E: numpy.number[Any] -reveal_type(A.min(axis=0)) # E: Union[numpy.number[Any], numpy.ndarray] -reveal_type(A.min(keepdims=True)) # E: Union[numpy.number[Any], numpy.ndarray] +reveal_type(f8.min()) # E: Any +reveal_type(A.min()) # E: Any +reveal_type(A.min(axis=0)) # E: Any +reveal_type(A.min(keepdims=True)) # E: Any reveal_type(A.min(out=B)) # E: SubClass reveal_type(f8.newbyteorder()) # E: numpy.floating[numpy.typing._64Bit] reveal_type(A.newbyteorder()) # E: numpy.ndarray reveal_type(B.newbyteorder('|')) # E: SubClass -reveal_type(f8.prod()) # E: numpy.number[Any] -reveal_type(A.prod()) # E: numpy.number[Any] -reveal_type(A.prod(axis=0)) # E: Union[numpy.number[Any], numpy.ndarray] -reveal_type(A.prod(keepdims=True)) # E: Union[numpy.number[Any], numpy.ndarray] +reveal_type(f8.prod()) # E: Any +reveal_type(A.prod()) # E: Any +reveal_type(A.prod(axis=0)) # E: Any +reveal_type(A.prod(keepdims=True)) # E: Any reveal_type(A.prod(out=B)) # E: SubClass -reveal_type(f8.ptp()) # E: numpy.number[Any] -reveal_type(A.ptp()) # E: numpy.number[Any] -reveal_type(A.ptp(axis=0)) # E: Union[numpy.number[Any], numpy.ndarray] -reveal_type(A.ptp(keepdims=True)) # E: Union[numpy.number[Any], numpy.ndarray] +reveal_type(f8.ptp()) # E: Any +reveal_type(A.ptp()) # E: Any +reveal_type(A.ptp(axis=0)) # E: Any +reveal_type(A.ptp(keepdims=True)) # E: Any reveal_type(A.ptp(out=B)) # E: SubClass reveal_type(f8.round()) # E: numpy.floating[numpy.typing._64Bit] @@ -111,40 +111,40 @@ class SubClass(np.ndarray): ... reveal_type(A.repeat(1)) # E: numpy.ndarray reveal_type(B.repeat(1)) # E: numpy.ndarray -reveal_type(f8.std()) # E: numpy.number[Any] -reveal_type(A.std()) # E: numpy.number[Any] -reveal_type(A.std(axis=0)) # E: Union[numpy.number[Any], numpy.ndarray] -reveal_type(A.std(keepdims=True)) # E: Union[numpy.number[Any], numpy.ndarray] +reveal_type(f8.std()) # E: Any +reveal_type(A.std()) # E: Any +reveal_type(A.std(axis=0)) # E: Any +reveal_type(A.std(keepdims=True)) # E: Any reveal_type(A.std(out=B)) # E: SubClass -reveal_type(f8.sum()) # E: numpy.number[Any] -reveal_type(A.sum()) # E: numpy.number[Any] -reveal_type(A.sum(axis=0)) # E: Union[numpy.number[Any], numpy.ndarray] -reveal_type(A.sum(keepdims=True)) # E: Union[numpy.number[Any], numpy.ndarray] +reveal_type(f8.sum()) # E: Any +reveal_type(A.sum()) # E: Any +reveal_type(A.sum(axis=0)) # E: Any +reveal_type(A.sum(keepdims=True)) # E: Any reveal_type(A.sum(out=B)) # E: SubClass -reveal_type(f8.take(0)) # E: numpy.generic -reveal_type(A.take(0)) # E: numpy.generic +reveal_type(f8.take(0)) # E: Any +reveal_type(A.take(0)) # E: Any reveal_type(A.take([0])) # E: numpy.ndarray reveal_type(A.take(0, out=B)) # E: SubClass reveal_type(A.take([0], out=B)) # E: SubClass -reveal_type(f8.var()) # E: numpy.number[Any] -reveal_type(A.var()) # E: numpy.number[Any] -reveal_type(A.var(axis=0)) # E: Union[numpy.number[Any], numpy.ndarray] -reveal_type(A.var(keepdims=True)) # E: Union[numpy.number[Any], numpy.ndarray] +reveal_type(f8.var()) # E: Any +reveal_type(A.var()) # E: Any +reveal_type(A.var(axis=0)) # E: Any +reveal_type(A.var(keepdims=True)) # E: Any reveal_type(A.var(out=B)) # E: SubClass reveal_type(A.argpartition([0])) # E: numpy.ndarray reveal_type(A.diagonal()) # E: numpy.ndarray -reveal_type(A.dot(1)) # E: Union[numpy.number[Any], numpy.ndarray] +reveal_type(A.dot(1)) # E: Any reveal_type(A.dot(1, out=B)) # E: SubClass reveal_type(A.nonzero()) # E: tuple[numpy.ndarray] reveal_type(A.searchsorted([1])) # E: numpy.ndarray -reveal_type(A.trace()) # E: Union[numpy.number[Any], numpy.ndarray] +reveal_type(A.trace()) # E: Any reveal_type(A.trace(out=B)) # E: SubClass From 222bc60d0f269b6cc4f51d14dcc79cef39bcf9ec Mon Sep 17 00:00:00 2001 From: Charles Harris Date: Sun, 11 Apr 2021 10:50:47 -0600 Subject: [PATCH 20/33] MAINT: Allow more recursion depth for scalar tests. The test_operator_object_left and test_operator_object_right tests in test_scalarmath.py set a maximum recursion depth of 100 that caused an error in gitpod because it was too close to the starting depth of 75. The fix here is to raise the maximum depth to 200. Closes #18749 --- numpy/core/tests/test_scalarmath.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/numpy/core/tests/test_scalarmath.py b/numpy/core/tests/test_scalarmath.py index e62a0f021374..19ac1c5c4b0e 100644 --- a/numpy/core/tests/test_scalarmath.py +++ b/numpy/core/tests/test_scalarmath.py @@ -737,7 +737,7 @@ def recursionlimit(n): @settings(verbosity=Verbosity.verbose) def test_operator_object_left(o, op, type_): try: - with recursionlimit(100): + with recursionlimit(200): op(o, type_(1)) except TypeError: pass @@ -748,7 +748,7 @@ def test_operator_object_left(o, op, type_): sampled_from(types)) def test_operator_object_right(o, op, type_): try: - with recursionlimit(100): + with recursionlimit(200): op(type_(1), o) except TypeError: pass From aaf8363c375d95d2ba665cbd1f4bd61399aa4f99 Mon Sep 17 00:00:00 2001 From: Sayed Adel Date: Tue, 4 May 2021 09:23:12 +0200 Subject: [PATCH 21/33] BLD: remove unnecessary flag `-faltivec` on macOS Supporting PowerPC/AltiVec on macOS is no longer necessary, even if the Mac/G5 is still running having `-faltivec` or replacing it with the new AltiVec flag `-maltivec` wouldn't increase that much performance without raw SIMD. note: the flag was enabled on non-intel platforms which causes fatal build errors on macOS/arm64. --- numpy/distutils/system_info.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/numpy/distutils/system_info.py b/numpy/distutils/system_info.py index 13f9da0fb684..d0a5859857da 100644 --- a/numpy/distutils/system_info.py +++ b/numpy/distutils/system_info.py @@ -2443,8 +2443,6 @@ def calc_info(self): 'accelerate' in libraries): if intel: args.extend(['-msse3']) - else: - args.extend(['-faltivec']) args.extend([ '-I/System/Library/Frameworks/vecLib.framework/Headers']) link_args.extend(['-Wl,-framework', '-Wl,Accelerate']) @@ -2453,8 +2451,6 @@ def calc_info(self): 'veclib' in libraries): if intel: args.extend(['-msse3']) - else: - args.extend(['-faltivec']) args.extend([ '-I/System/Library/Frameworks/vecLib.framework/Headers']) link_args.extend(['-Wl,-framework', '-Wl,vecLib']) From 01687f4b155802c21124770c7c7f694edc869b06 Mon Sep 17 00:00:00 2001 From: Dong Keun Oh Date: Wed, 5 May 2021 15:26:35 +0900 Subject: [PATCH 22/33] BUG FIX for MINGW : threads.h existence test requires GLIBC > 2.12 --- numpy/f2py/cfuncs.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/numpy/f2py/cfuncs.py b/numpy/f2py/cfuncs.py index 974062f2617a..f403a66b5d7b 100644 --- a/numpy/f2py/cfuncs.py +++ b/numpy/f2py/cfuncs.py @@ -545,7 +545,9 @@ """ cppmacros["F2PY_THREAD_LOCAL_DECL"] = """\ #ifndef F2PY_THREAD_LOCAL_DECL -#if defined(_MSC_VER) +#if defined(_MSC_VER) \\ + || defined(_WIN32) || defined(_WIN64) \\ + || defined(__MINGW32__) || defined(__MINGW64__) #define F2PY_THREAD_LOCAL_DECL __declspec(thread) #elif defined(__STDC_VERSION__) \\ && (__STDC_VERSION__ >= 201112L) \\ From 92da57b6f8111c05184b45081b39269e90fa93dd Mon Sep 17 00:00:00 2001 From: Sebastian Berg Date: Mon, 19 Apr 2021 19:16:58 -0500 Subject: [PATCH 23/33] BUG: Initialize the full nditer buffer in case of error This is necessary because in some rare cases (reductions), we may not actually use the full buffer. In that case, the cleanup-on-error code would have to grow smart enough to handle these cases. It seems much simpler to just always initialize the full buffers, even if we may not end up using them. Admittedly, the old logic might have skipped the buffer clearing (especially the full buffer) in a fair bit of cases, but since this is only relevant for `object` dtype, I assume this is fine. --- numpy/core/src/multiarray/nditer_api.c | 3 +++ numpy/core/src/multiarray/nditer_constr.c | 3 +++ numpy/core/tests/test_nditer.py | 19 +++++++++++++++++++ 3 files changed, 25 insertions(+) diff --git a/numpy/core/src/multiarray/nditer_api.c b/numpy/core/src/multiarray/nditer_api.c index cf28b8a8a68f..fad1195f3815 100644 --- a/numpy/core/src/multiarray/nditer_api.c +++ b/numpy/core/src/multiarray/nditer_api.c @@ -1758,6 +1758,9 @@ npyiter_allocate_buffers(NpyIter *iter, char **errmsg) } goto fail; } + if (PyDataType_FLAGCHK(op_dtype[iop], NPY_NEEDS_INIT)) { + memset(buffer, '\0', itemsize*buffersize); + } buffers[iop] = buffer; } } diff --git a/numpy/core/src/multiarray/nditer_constr.c b/numpy/core/src/multiarray/nditer_constr.c index b379a28ac3ae..ab1e27ea5e2b 100644 --- a/numpy/core/src/multiarray/nditer_constr.c +++ b/numpy/core/src/multiarray/nditer_constr.c @@ -596,6 +596,9 @@ NpyIter_Copy(NpyIter *iter) if (buffers[iop] == NULL) { out_of_memory = 1; } + if (PyDataType_FLAGCHK(dtypes[iop], NPY_NEEDS_INIT)) { + memset(buffers[iop], '\0', itemsize*buffersize); + } } } diff --git a/numpy/core/tests/test_nditer.py b/numpy/core/tests/test_nditer.py index cb6d77bd7226..93347f4d4f2e 100644 --- a/numpy/core/tests/test_nditer.py +++ b/numpy/core/tests/test_nditer.py @@ -2746,6 +2746,25 @@ def __bool__(self): assert_raises(TypeError, np.logical_or.reduce, np.array([T(), T()], dtype='O')) +def test_object_iter_cleanup_reduce(): + # Similar as above, but a complex reduction case that was previously + # missed (see gh-18810)/ + # the following array is special in that it cananot be flattened: + arr = np.array([[None, 1], [-1, -1], [None, 2], [-1, -1]])[::2] + with pytest.raises(TypeError): + np.sum(arr) + +@pytest.mark.parametrize("arr", [ + np.ones((8000, 4, 2), dtype=object)[:, ::2, :], + np.ones((8000, 4, 2), dtype=object, order="F")[:, ::2, :], + np.ones((8000, 4, 2), dtype=object)[:, ::2, :].copy("F")]) +def test_object_iter_cleanup_large_reduce(arr): + # More complicated calls are possible for large arrays: + out = np.ones(8000, dtype=np.intp) + # force casting with `dtype=object` + res = np.sum(arr, axis=(1, 2), dtype=object, out=out) + assert_array_equal(res, np.full(8000, 4, dtype=object)) + def test_iter_too_large(): # The total size of the iterator must not exceed the maximum intp due # to broadcasting. Dividing by 1024 will keep it small enough to From acf6648a5a155c45314e1fb24b07e4a9f4dfabec Mon Sep 17 00:00:00 2001 From: Sebastian Berg Date: Mon, 19 Apr 2021 19:20:50 -0500 Subject: [PATCH 24/33] MAINT: Remove buffer-clearing from copy code Buffer must always either contain NULL or valid references (assuming the dtype supports references) in order to allow cleanup in case of errors. It is thus unnecessary to clear buffers before every copy, if they contain NULL, all is fine. If they contain non-NULL, we should also DECREF those references (so it would be incorrect as well). Buffers thus need the memset exactly once: directly upon allcoation (which we do now). After this any transfer from/to the buffer needs to ensure that the buffer is always in a good state. --- numpy/core/src/multiarray/nditer_api.c | 32 ++++++++++---------------- numpy/core/tests/test_nditer.py | 4 ++-- 2 files changed, 14 insertions(+), 22 deletions(-) diff --git a/numpy/core/src/multiarray/nditer_api.c b/numpy/core/src/multiarray/nditer_api.c index fad1195f3815..9a1dc9d90756 100644 --- a/numpy/core/src/multiarray/nditer_api.c +++ b/numpy/core/src/multiarray/nditer_api.c @@ -2542,16 +2542,18 @@ npyiter_copy_to_buffers(NpyIter *iter, char **prev_dataptrs) skip_transfer = 1; } - /* If the data type requires zero-inititialization */ - if (PyDataType_FLAGCHK(dtypes[iop], NPY_NEEDS_INIT)) { - NPY_IT_DBG_PRINT("Iterator: Buffer requires init, " - "memsetting to 0\n"); - memset(ptrs[iop], 0, dtypes[iop]->elsize*op_transfersize); - /* Can't skip the transfer in this case */ - skip_transfer = 0; - } - - if (!skip_transfer) { + /* + * Copy data to the buffers if necessary. + * + * We always copy if the operand has references. In that case + * a "write" function must be in use that either copies or clears + * the buffer. + * This write from buffer call does not check for skip-transfer + * so we have to assume the buffer is cleared. For dtypes that + * do not have references, we can assume that the write function + * will leave the source (buffer) unmodified. + */ + if (!skip_transfer || PyDataType_REFCHK(dtypes[iop])) { NPY_IT_DBG_PRINT2("Iterator: Copying operand %d to " "buffer (%d items)\n", (int)iop, (int)op_transfersize); @@ -2567,16 +2569,6 @@ npyiter_copy_to_buffers(NpyIter *iter, char **prev_dataptrs) } } } - else if (ptrs[iop] == buffers[iop]) { - /* If the data type requires zero-inititialization */ - if (PyDataType_FLAGCHK(dtypes[iop], NPY_NEEDS_INIT)) { - NPY_IT_DBG_PRINT1("Iterator: Write-only buffer for " - "operand %d requires init, " - "memsetting to 0\n", (int)iop); - memset(ptrs[iop], 0, dtypes[iop]->elsize*transfersize); - } - } - } /* diff --git a/numpy/core/tests/test_nditer.py b/numpy/core/tests/test_nditer.py index 93347f4d4f2e..14c06b59c636 100644 --- a/numpy/core/tests/test_nditer.py +++ b/numpy/core/tests/test_nditer.py @@ -2748,8 +2748,8 @@ def __bool__(self): def test_object_iter_cleanup_reduce(): # Similar as above, but a complex reduction case that was previously - # missed (see gh-18810)/ - # the following array is special in that it cananot be flattened: + # missed (see gh-18810). + # The following array is special in that it cannot be flattened: arr = np.array([[None, 1], [-1, -1], [None, 2], [-1, -1]])[::2] with pytest.raises(TypeError): np.sum(arr) From cbfe84725bbf7c37ff2181df9d888e4916118f44 Mon Sep 17 00:00:00 2001 From: Sayed Adel Date: Tue, 4 May 2021 13:15:37 +0200 Subject: [PATCH 25/33] MAINT: Avoid treating _SIMD module build warnings as errors --- numpy/core/src/_simd/_simd.dispatch.c.src | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/numpy/core/src/_simd/_simd.dispatch.c.src b/numpy/core/src/_simd/_simd.dispatch.c.src index 18c38387165c..c3db12e895fa 100644 --- a/numpy/core/src/_simd/_simd.dispatch.c.src +++ b/numpy/core/src/_simd/_simd.dispatch.c.src @@ -1,4 +1,4 @@ -/*@targets $werror #simd_test*/ +/*@targets #simd_test*/ #include "_simd.h" #include "_simd_inc.h" From b0e2606e0f4cd9e5b2d4e9e71cc71872ba81f80d Mon Sep 17 00:00:00 2001 From: Charles Harris Date: Thu, 6 May 2021 17:47:50 -0600 Subject: [PATCH 26/33] BUG: Make changelog recognize ``gh-`` as PR number prefix. The changelog.py script was only recognizing fast forward merges where the PR number was of the form "(#xxxxx)", but some people were merging using the "(gh-xxxxx)" form. Fix that. --- tools/changelog.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/tools/changelog.py b/tools/changelog.py index 920f5b87faa3..9da330500726 100755 --- a/tools/changelog.py +++ b/tools/changelog.py @@ -66,10 +66,14 @@ def get_authors(revision_range): pre = set(re.findall(pat, this_repo.git.shortlog('-s', lst_release), re.M)) - # Homu is the author of auto merges, clean him out. + # Ignore the bot Homu. cur.discard('Homu') pre.discard('Homu') + # Ignore the bot dependabot-preview + cur.discard('dependabot-preview') + pre.discard('dependabot-preview') + # Append '+' to new authors. authors = [s + u' +' for s in cur - pre] + [s for s in cur & pre] authors.sort() @@ -92,8 +96,8 @@ def get_pull_requests(repo, revision_range): # From fast forward squash-merges commits = this_repo.git.log( '--oneline', '--no-merges', '--first-parent', revision_range) - issues = re.findall(u'^.*\\(\\#(\\d+)\\)$', commits, re.M) - prnums.extend(int(s) for s in issues) + issues = re.findall(u'^.*\\((\\#|gh-|gh-\\#)(\\d+)\\)$', commits, re.M) + prnums.extend(int(s[1]) for s in issues) # get PR data from github repo prnums.sort() From 51f5b835e29712789663add7e82dc83a8cf48572 Mon Sep 17 00:00:00 2001 From: Charles Harris Date: Thu, 6 May 2021 17:52:04 -0600 Subject: [PATCH 27/33] DOC: Update 1.20.0-changelog.rst. --- doc/changelog/1.20.0-changelog.rst | 144 ++++++++++++++++++----------- 1 file changed, 88 insertions(+), 56 deletions(-) diff --git a/doc/changelog/1.20.0-changelog.rst b/doc/changelog/1.20.0-changelog.rst index f0c2a27234f7..f06bd8a8d22d 100644 --- a/doc/changelog/1.20.0-changelog.rst +++ b/doc/changelog/1.20.0-changelog.rst @@ -193,41 +193,47 @@ names contributed a patch for the first time. Pull requests merged ==================== -A total of 684 pull requests were merged for this release. +A total of 716 pull requests were merged for this release. * `#13516 `__: ENH: enable multi-platform SIMD compiler optimizations * `#14779 `__: NEP 36 (fair play) * `#14882 `__: DEP: Deprecate aliases of builtin types in python 3.7+ -* `#15037 `__: BUG: `np.resize` negative shape and subclasses edge case fixes -* `#15121 `__: ENH: random: Add the method `permuted` to Generator. +* `#15037 `__: BUG: ``np.resize`` negative shape and subclasses edge case fixes +* `#15121 `__: ENH: random: Add the method ``permuted`` to Generator. * `#15162 `__: BUG,MAINT: Fix issues with non-reduce broadcasting axes * `#15471 `__: BUG: Ensure PyArray_FromScalar always returns the requested dtype * `#15507 `__: NEP 42: Technical decisions for new DTypes * `#15508 `__: API: Create Preliminary DTypeMeta class and np.dtype subclasses +* `#15551 `__: DOC: Simd optimization documentation * `#15604 `__: MAINT: Avoid exception in NpzFile destructor if constructor raises... -* `#15666 `__: ENH: Improved `__str__` for polynomials +* `#15666 `__: ENH: Improved ``__str__`` for polynomials * `#15759 `__: BUILD: Remove Accelerate support * `#15791 `__: [DOC] Added tutorial about the numpy.ma module. * `#15852 `__: ENH: Add where argument to np.mean * `#15886 `__: DEP: Deprecate passing shape=None to mean shape=() * `#15900 `__: DEP: Ensure indexing errors will be raised even on empty results * `#15997 `__: ENH: improve printing of arrays with multi-line reprs +* `#16056 `__: DEP: Deprecate inexact matches for mode, searchside * `#16130 `__: DOC: Correct documentation of ``__array__`` when used as output... * `#16134 `__: ENH: Implement concatenate dtype and casting keyword arguments -* `#16156 `__: DEP: Deprecate `numpy.dual`. +* `#16156 `__: DEP: Deprecate ``numpy.dual``. * `#16161 `__: BUG: Potential fix for divmod(1.0, 0.0) to raise divbyzero and... * `#16167 `__: DOC: Increase guidance and detail of np.polynomial docstring * `#16174 `__: DOC: Add transition note to all lib/poly functions * `#16200 `__: ENH: Rewrite of array-coercion to support new dtypes * `#16205 `__: ENH: Add ``full_output`` argument to ``f2py.compile``. +* `#16207 `__: DOC: Add PyArray_ContiguousFromObject C docs * `#16232 `__: DEP: Deprecate ufunc.outer with matrix inputs +* `#16237 `__: MAINT: precompute ``log(2.0 * M_PI)`` in ``random_loggam`` * `#16238 `__: MAINT: Unify cached (C-level static) imports * `#16239 `__: BUG,DOC: Allow attach docs twice but error if wrong * `#16242 `__: BUG: Fix default fallback in genfromtxt * `#16247 `__: ENH:Umath Replace raw SIMD of unary float point(32-64) with NPYV... * `#16248 `__: MRG, ENH: added edge keyword argument to digitize +* `#16253 `__: DOC: Clarify tiny/xmin in finfo and machar +* `#16254 `__: MAINT: Chain exceptions in generate_umath.py * `#16257 `__: DOC: Update the f2py section of the "Using Python as Glue" page. -* `#16260 `__: DOC: Improve `rec.array` function documentation (#15853) +* `#16260 `__: DOC: Improve ``rec.array`` function documentation * `#16266 `__: ENH: include dt64/td64 isinstance checks in ``__init__.pxd`` * `#16267 `__: DOC: Clarifications for np.std * `#16273 `__: BUG: Order percentile monotonically @@ -238,6 +244,7 @@ A total of 684 pull requests were merged for this release. * `#16283 `__: DOC: Add a note about performance of isclose compared to math.isclose * `#16284 `__: MAINT: Clean up the implementation of quantile * `#16285 `__: MAINT: Bump hypothesis from 5.12.0 to 5.14.0 +* `#16288 `__: BLD: Avoid "visibility attribute not supported" warning * `#16291 `__: DOC: Improve "tobytes" docstring. * `#16292 `__: BUG: Fix tools/download-wheels.py. * `#16295 `__: BUG: Require Python >= 3.6 in setup.py @@ -254,14 +261,17 @@ A total of 684 pull requests were merged for this release. * `#16318 `__: MAINT: Stop Using PyEval_Call* and simplify some uses * `#16321 `__: ENH: Improve the ARM cpu feature detection by parsing /proc/cpuinfo * `#16323 `__: DOC: Reconstruct Testing Guideline. +* `#16327 `__: BUG: Don't segfault on bad __len__ when assigning. * `#16329 `__: MAINT: Cleanup 'tools/download-wheels.py' * `#16332 `__: DOC: link np.interp to SciPy's interpolation functions (closes... * `#16333 `__: DOC: Fix spelling typo - homogenous to homogeneous. (#16324) * `#16334 `__: ENH: Use AVX-512 for np.isnan, np.infinite, np.isinf and np.signbit * `#16336 `__: BUG: Fix refcounting in add_newdoc * `#16337 `__: CI: Create a link for the circleCI artifact -* `#16348 `__: BUG: Fix dtype leak in `PyArray_FromAny` error path +* `#16346 `__: MAINT: Remove f-strings in setup.py. +* `#16348 `__: BUG: Fix dtype leak in ``PyArray_FromAny`` error path * `#16349 `__: BUG: Indentation for docstrings +* `#16350 `__: BUG: Set readonly flag in array interface * `#16351 `__: BUG: Fix small leaks in error path and ``empty_like`` with shape * `#16362 `__: MAINT: Streamline download-wheels. * `#16365 `__: DOC: Fix an obvious mistake in a message printed in doc/Makefile. @@ -301,6 +311,7 @@ A total of 684 pull requests were merged for this release. * `#16447 `__: DOC: add a "make show" command to doc/Makefile * `#16450 `__: DOC: Add a NEP link to all neps. * `#16452 `__: DOC,ENH: extend error message when Accelerate is detected +* `#16454 `__: TST: Add tests for PyArray_IntpConverter * `#16463 `__: DOC: Improve assert_warns docstring with example * `#16464 `__: MAINT: Bump hypothesis from 5.15.1 to 5.16.0 * `#16465 `__: DOC: Fix development_workflow links @@ -308,7 +319,7 @@ A total of 684 pull requests were merged for this release. * `#16471 `__: BLD: install mingw32 v7.3.0 for win32 * `#16472 `__: DOC: Fixes for 18 broken links * `#16474 `__: MAINT: use zip instead of range in piecewise -* `#16476 `__: ENH: add `norm=forward,backward` to numpy.fft functions +* `#16476 `__: ENH: add ``norm=forward,backward`` to numpy.fft functions * `#16482 `__: SIMD: Optimize the performace of np.packbits in ARM-based machine. * `#16485 `__: BUG: Fix result when a gufunc output broadcasts the inputs. * `#16500 `__: DOC: Point Contributing page to new NEP 45 @@ -340,6 +351,7 @@ A total of 684 pull requests were merged for this release. * `#16574 `__: MAINT: fix name of first parameter to dtype constructor in type... * `#16581 `__: DOC: Added an example for np.transpose(4d_array) * `#16583 `__: MAINT: changed np.generic arguments to positional-only +* `#16589 `__: MAINT: Remove nickname from polynomial classes. * `#16590 `__: DOC: Clarify dtype default for logspace and geomspace * `#16591 `__: DOC: Disallow complex args in arange * `#16592 `__: BUG: Raise TypeError for float->timedelta promotion @@ -364,8 +376,9 @@ A total of 684 pull requests were merged for this release. * `#16633 `__: MAINT: lib: Some code clean up in loadtxt * `#16635 `__: BENCH: remove obsolete goal_time param * `#16639 `__: BUG: Fix uint->timedelta promotion to raise TypeError -* `#16642 `__: MAINT: Replace `PyUString_GET_SIZE` with `PyUnicode_GetLength`. +* `#16642 `__: MAINT: Replace ``PyUString_GET_SIZE`` with ``PyUnicode_GetLength``. * `#16643 `__: REL: Fix outdated docs link +* `#16644 `__: MAINT: Improve performance of np.full * `#16646 `__: TST: add a static typing test for memoryviews as ArrayLikes * `#16647 `__: ENH: Added annotations to 8 functions from np.core.fromnumeric * `#16648 `__: REL: Update master after 1.19.0 release. @@ -377,14 +390,15 @@ A total of 684 pull requests were merged for this release. * `#16664 `__: DOC: Add lib.format.open_memmap to autosummary. * `#16666 `__: BUG: Fix bug in AVX complex absolute while processing array of... * `#16669 `__: MAINT: remove blacklist/whitelist terms +* `#16671 `__: DOC: Simplify and update git setup page * `#16674 `__: TST: Add extra debugging information to CPU features detection * `#16675 `__: ENH: Add support for file like objects to np.core.records.fromfile * `#16683 `__: DOC: updated gcc minimum recommend version to build from source -* `#16684 `__: MAINT: Allow `None` to be passed to certain `generic` subclasses +* `#16684 `__: MAINT: Allow None to be passed to certain generic subclasses * `#16690 `__: DOC: fixed docstring for descr_to_dtype -* `#16691 `__: DOC: Remove "matrix" from `triu` docstring. +* `#16691 `__: DOC: Remove "matrix" from ``triu`` docstring. * `#16696 `__: MAINT: add py.typed sentinel to package manifest -* `#16699 `__: MAINT: Fixup quantile tests to not use `np.float` +* `#16699 `__: MAINT: Fixup quantile tests to not use ``np.float`` * `#16702 `__: BLD: Add CPU entry for Emscripten / WebAssembly * `#16704 `__: TST: Disable Python 3.9-dev testing. * `#16706 `__: DOC: Add instruction about stable symlink @@ -393,11 +407,12 @@ A total of 684 pull requests were merged for this release. * `#16710 `__: ENH, BLD: Add RPATH support for AIX * `#16718 `__: DOC: fix typo * `#16720 `__: BUG: Fix PyArray_SearchSorted signature. +* `#16723 `__: NEP: Initial draft for NEP 43 for extensible ufuncs * `#16729 `__: ENH: Add annotations to the last 8 functions in numpy.core.fromnumeric * `#16730 `__: ENH: Use f90 compiler specified in f2py command line args for... * `#16731 `__: DOC: reword random c-api introduction, cython is documented in... * `#16735 `__: DOC: Tweak a sentence about broadcasting. -* `#16736 `__: DOC: Prepend `ma.` to references in ``numpy.ma`` +* `#16736 `__: DOC: Prepend ``ma.`` to references in ``numpy.ma`` * `#16738 `__: DOC: Remove redundant word * `#16742 `__: DOC: add unique() to See Also of repeat() * `#16743 `__: DOC: add example to unique() and make connection to repeat() @@ -414,6 +429,8 @@ A total of 684 pull requests were merged for this release. * `#16770 `__: MAINT: Remove unneeded call to PyUnicode_READY * `#16771 `__: MAINT: Fix deprecated functions in scalarapi.c * `#16775 `__: DOC: switch to logo with text +* `#16777 `__: BUG: Added missing return after raising error in methods.c +* `#16778 `__: NEP: Update NEP 42 to note the issue of circular references * `#16782 `__: ENH, TST: Bring the NumPy C SIMD vectorization interface "NPYV"... * `#16786 `__: BENCH: Add basic benchmarks for scalar indexing and assignment * `#16789 `__: BUG: fix decode error when building and get rid of warn @@ -467,7 +484,8 @@ A total of 684 pull requests were merged for this release. * `#16886 `__: DOC: Fix types including curly braces * `#16887 `__: DOC: Remove the links for ``True`` and ``False`` * `#16888 `__: ENH: Integrate the new CPU dispatcher with umath generator -* `#16894 `__: DOC: Fix wrong markups in `arrays.dtypes` +* `#16890 `__: TST, BUG: Re-raise MemoryError exception in test_large_zip's... +* `#16894 `__: DOC: Fix wrong markups in ``arrays.dtypes`` * `#16896 `__: DOC: Remove links for C codes * `#16897 `__: DOC: Fix the declarations of C fuctions * `#16899 `__: MNT: also use Py_SET_REFCNT instead of Py_REFCNT @@ -480,23 +498,24 @@ A total of 684 pull requests were merged for this release. * `#16919 `__: DOC: Add ufunc docstring to generated docs. * `#16925 `__: REL: Update master after 1.19.1 release. * `#16931 `__: Revert "Merge pull request #16248 from alexrockhill/edge" +* `#16935 `__: ENH: implement NEP-35's ``like=`` argument * `#16936 `__: BUG: Fix memory leak of buffer-info cache due to relaxed strides * `#16938 `__: ENH,API: Store exported buffer info on the array * `#16940 `__: BLD: update OpenBLAS build * `#16941 `__: BUG: Allow array-like types to be coerced as object array elements * `#16943 `__: DEP: Deprecate size-one ragged array coercion * `#16944 `__: Change the name of the folder "icons" to "logo". -* `#16949 `__: ENH: enable colors for `runtests.py --ipython` +* `#16949 `__: ENH: enable colors for ``runtests.py --ipython`` * `#16950 `__: DOC: Clarify input to irfft/irfft2/irfftn * `#16952 `__: MAINT: Bump hypothesis from 5.20.2 to 5.23.2 * `#16953 `__: update numpy/lib/arraypad.py with appropriate chain exception * `#16957 `__: MAINT: Use arm64 instead of aarch64 on travisCI. * `#16962 `__: MAINT: Chain exception in ``distutils/fcompiler/environment.py``. -* `#16966 `__: MAINT: Added the `order` parameter to `np.array()` +* `#16966 `__: MAINT: Added the ``order`` parameter to ``np.array()`` * `#16969 `__: ENH: Add Neon SIMD implementations for add, sub, mul, and div * `#16973 `__: DOC: Fixed typo in lib/recfunctions.py * `#16974 `__: TST: Add pypy win32 CI testing. -* `#16982 `__: ENH: Increase the use of `Literal` types +* `#16982 `__: ENH: Increase the use of ``Literal`` types * `#16986 `__: ENH: Add NumPy declarations to be used by Cython 3.0+ * `#16988 `__: DOC: Add the new NumPy logo to Sphinx pages * `#16991 `__: MAINT: Bump hypothesis from 5.23.2 to 5.23.9 @@ -505,18 +524,24 @@ A total of 684 pull requests were merged for this release. * `#16996 `__: DOC: Revise glossary page * `#17002 `__: DOC: clip() allows arguments. * `#17009 `__: NEP: Updated NEP-35 with keyword-only instruction +* `#17010 `__: BUG: Raise correct errors in boolean indexing fast path * `#17013 `__: MAINT: Simplify scalar power * `#17014 `__: MAINT: Improve error handling in umathmodule setup +* `#17022 `__: DOC: Fix non-matching pronoun. * `#17028 `__: DOC: Disclaimer for FFT library * `#17029 `__: MAINT: Add error return to all casting functionality and NpyIter * `#17033 `__: BUG: fix a compile and a test warning -* `#17036 `__: DOC: Clarify that `np.char` comparison functions always return... +* `#17036 `__: DOC: Clarify that ``np.char`` comparison functions always return... * `#17039 `__: DOC: Use a less ambiguous example for array_split * `#17041 `__: MAINT: Bump hypothesis from 5.23.9 to 5.23.12 * `#17048 `__: STY: core._internal style fixups * `#17050 `__: MAINT: Remove _EXTRAFLAGS variable +* `#17050 `__: MAINT: change ``for line in open()`` to ``with open() as f`` +* `#17052 `__: MAINT: Delete obsolete conversion to list * `#17053 `__: BUG: fix typo in polydiv that prevented promotion to poly1d +* `#17055 `__: MAINT: Replace lambda function by list comprehension * `#17058 `__: MAINT: Revert boolean casting back to elementwise comparisons... +* `#17059 `__: BUG: fix pickling of arrays larger than 2GiB * `#17062 `__: API, BUG: Raise error on complex input to i0 * `#17063 `__: MAINT: Remove obsolete conversion to set * `#17067 `__: DEP: lib: Remove the deprecated financial functions. @@ -530,7 +555,7 @@ A total of 684 pull requests were merged for this release. * `#17109 `__: MAINT: Split einsum into multiple files * `#17112 `__: BUG: Handle errors from the PyCapsule API * `#17115 `__: DOC: Fix spacing in vectorize doc -* `#17116 `__: API: Remove `np.ctypeslib.ctypes_load_library` +* `#17116 `__: API: Remove ``np.ctypeslib.ctypes_load_library`` * `#17119 `__: DOC: make spacing consistent in NEP 41 bullet points * `#17121 `__: BUG: core: fix ilp64 blas dot/vdot/... for strides > int32 max * `#17123 `__: ENH: allow running mypy through runtests.py @@ -542,13 +567,13 @@ A total of 684 pull requests were merged for this release. * `#17141 `__: MAINT: Make arrayprint str and repr the ndarray defaults. * `#17142 `__: DOC: NEP-42: Fix a few typos. * `#17143 `__: MAINT: Change handling of the expired financial functions. -* `#17144 `__: ENH: Add annotations to 3 functions in `np.core.function_base` +* `#17144 `__: ENH: Add annotations to 3 functions in ``np.core.function_base`` * `#17145 `__: MAINT, BUG: Replace uses of PyString_AsString. * `#17146 `__: MAINT: ``Replace PyUString_*`` by ``PyUnicode_*`` equivalents. * `#17149 `__: MAINT: Replace PyInt macros with their PyLong replacement * `#17150 `__: ENH: Add support for the abstract scalars to cython code * `#17151 `__: BUG: Fix incorrect cython definition of npy_cfloat -* `#17152 `__: MAINT: Clean up some Npy_ vs Py_ macro usage +* `#17152 `__: MAINT: Clean up some ``Npy_`` vs ``Py_`` macro usage * `#17154 `__: DOC: Remove references to PyCObject * `#17159 `__: DOC: Update numpy4matlab * `#17160 `__: Clean up some more bytes vs unicode handling @@ -558,22 +583,23 @@ A total of 684 pull requests were merged for this release. * `#17167 `__: BLD: Merge the npysort library into multiarray * `#17168 `__: TST: Add tests mapping out the rules for metadata in promotion * `#17171 `__: BUG: revert trim_zeros changes from gh-16911 -* `#17172 `__: ENH: Make `np.complexfloating` generic w.r.t. `np.floating` +* `#17172 `__: ENH: Make ``np.complexfloating`` generic w.r.t. ``np.floating`` * `#17176 `__: MAINT/ENH: datetime: remove calls to PyUnicode_AsASCIIString,... -* `#17180 `__: ENH: Added missing methods to `np.flatiter` +* `#17180 `__: ENH: Added missing methods to ``np.flatiter`` * `#17181 `__: DOC: Correct error in description of ndarray.base -* `#17182 `__: DOC: Document `dtype.metadata` +* `#17182 `__: DOC: Document ``dtype.metadata`` * `#17186 `__: MAINT: Use utf8 strings in more of datetime -* `#17188 `__: MAINT: Add placeholder stubs for `ndarray` and `generic` +* `#17188 `__: MAINT: Add placeholder stubs for ``ndarray`` and ``generic`` * `#17191 `__: MAINT: Bump hypothesis from 5.26.0 to 5.30.0 * `#17193 `__: MAINT: Remove some callers of functions in numpy.compat * `#17195 `__: ENH: Make the window functions exactly symmetric * `#17197 `__: MAINT: Improve error handling in npy_cpu_init -* `#17199 `__: DOC: Fix the documented signatures of four `ufunc` methods -* `#17201 `__: MAINT: Make the `NPY_CPU_DISPATCH_CALL` macros expressions not... +* `#17199 `__: DOC: Fix the documented signatures of four ``ufunc`` methods +* `#17201 `__: MAINT: Make the ``NPY_CPU_DISPATCH_CALL`` macros expressions not... * `#17204 `__: DOC: Fixed headings for tutorials so they appear at new theme... * `#17210 `__: DOC: Canonical_urls -* `#17214 `__: MAINT: Fix various issues with the `np.generic` annotations +* `#17214 `__: MAINT: Fix various issues with the ``np.generic`` annotations +* `#17215 `__: DOC: Use official MATLAB spelling in numpy-for-matlab-users.rst * `#17219 `__: BLD: enabled negation of library choices in NPY_*_ORDER * `#17220 `__: BUG, DOC: comment out metadata added via javascript * `#17222 `__: MAINT, DOC: move informational files from numpy.doc.*.py to their... @@ -583,7 +609,9 @@ A total of 684 pull requests were merged for this release. * `#17233 `__: DEP: Deprecated ndindex.ndincr * `#17235 `__: MAINT: Remove old PY_VERSION_HEX and sys.version_info code * `#17237 `__: BUG: Avoid using ``np.random`` in typing tests. +* `#17238 `__: DOC: Use SPDX license expressions with correct license * `#17239 `__: DOC: Fix link quick-start in old random API functions +* `#17240 `__: MAINT: added exception chaining in shape_base.py * `#17241 `__: MAINT: ``__array_interface__`` data address cannot be bytes * `#17242 `__: MAINT: Run slow CI jobs earlier so builds finishes sooner * `#17247 `__: ENH: Add tool to help speed up Travis CI @@ -595,9 +623,9 @@ A total of 684 pull requests were merged for this release. * `#17260 `__: MAINT: Bump pydata-sphinx-theme from 0.3.2 to 0.4.0 * `#17263 `__: DOC: add new glossary terms * `#17264 `__: DOC: remove some glosssary terms -* `#17267 `__: TST: Fix the path to `mypy.ini` in `runtests.py` +* `#17267 `__: TST: Fix the path to ``mypy.ini`` in ``runtests.py`` * `#17268 `__: BUG: sysconfig attributes/distutils issue -* `#17273 `__: ENH: Annotate the arithmetic operations of `ndarray` and `generic` +* `#17273 `__: ENH: Annotate the arithmetic operations of ``ndarray`` and ``generic`` * `#17278 `__: MAINT: Merge together index page content into a single file * `#17279 `__: DOC: Fix a typo in shape_base. * `#17284 `__: ENH: Pass optimizations arguments to asv build @@ -616,23 +644,23 @@ A total of 684 pull requests were merged for this release. * `#17304 `__: BUILD: pin pygments to 2.6.1, 2.7.0 breaks custom NumPyC lexer * `#17307 `__: MAINT: Bump hypothesis from 5.33.0 to 5.35.1 * `#17308 `__: MAINT: Bump pytest from 6.0.1 to 6.0.2 -* `#17309 `__: MAINT: Move the `fromnumeric` annotations to their own stub file +* `#17309 `__: MAINT: Move the ``fromnumeric`` annotations to their own stub file * `#17312 `__: MAINT: Syntax-highlight .src files on github * `#17313 `__: MAINT: Mark vendored/generated files in .gitattributes * `#17315 `__: MAINT: Cleanup f2py/cfuncs.py * `#17319 `__: BUG: Set deprecated fields to null in PyArray_InitArrFuncs * `#17320 `__: BUG: allow registration of hard-coded structured dtypes * `#17326 `__: ENH: Add annotations for five array construction functions -* `#17329 `__: DOC: Fix incorrect `.. deprecated::` syntax that led to this... -* `#17330 `__: DOC: improve `issubdtype` and scalar type docs -* `#17331 `__: DOC: Remove the tables of scalar types, and use `..autoclass`... +* `#17329 `__: DOC: Fix incorrect ``.. deprecated::`` syntax that led to this... +* `#17330 `__: DOC: improve ``issubdtype`` and scalar type docs +* `#17331 `__: DOC: Remove the tables of scalar types, and use ``..autoclass``... * `#17332 `__: DOC, BLD: update lexer highlighting and make numpydocs a regular... * `#17334 `__: MAINT: Chaining exceptions in npyio.py * `#17337 `__: NEP: Regenerate table in NEP 29 (add numpy 1.18 and 1.19 to list) * `#17338 `__: DOC: Fix syntax errors in docstrings for versionchanged, versionadded * `#17340 `__: SIMD: Add partial/non-contig load and store intrinsics for 32/64-bit * `#17344 `__: ENH, BLD: Support for the NVIDIA HPC SDK nvfortran compiler -* `#17346 `__: BLD,BUG: Fix a macOS build failure when `NPY_BLAS_ORDER=""` +* `#17346 `__: BLD,BUG: Fix a macOS build failure when ``NPY_BLAS_ORDER=""`` * `#17350 `__: DEV: Add PR prefix labeler and numpy prefix mapping * `#17352 `__: DOC: Guide to writing how-tos * `#17353 `__: DOC: How-to guide for I/O @@ -642,7 +670,7 @@ A total of 684 pull requests were merged for this release. * `#17364 `__: MAINT: Finish replacing PyInt_Check * `#17369 `__: DOC: distutils: Remove an obsolete paragraph. * `#17370 `__: NEP: Edit nep-0042 for more clarity -* `#17372 `__: ENH: Add annotations for remaining `ndarray` / `generic` non-magic... +* `#17372 `__: ENH: Add annotations for remaining ``ndarray`` / ``generic`` non-magic... * `#17373 `__: BUG: Fixes module data docstrings. * `#17375 `__: DOC: Fix default_rng docstring * `#17377 `__: BUG: ensure _UFuncNoLoopError can be pickled @@ -654,6 +682,7 @@ A total of 684 pull requests were merged for this release. * `#17391 `__: DOC: Replace "About NumPy" with "Document conventions" * `#17392 `__: DOC: Update info on doc style rules * `#17393 `__: BUG: Fix default void, datetime, and timedelta in array coercion +* `#17394 `__: ENH: Implement sliding window * `#17396 `__: MAINT: Replace append_metastr_to_string function. * `#17399 `__: BLD: Fixed ARGOUTVIEWM memory deallocation. Closes #17398. * `#17400 `__: DOC: rm incorrect alias from recarray user article. @@ -661,12 +690,12 @@ A total of 684 pull requests were merged for this release. * `#17402 `__: DOC: Add arraysetops to an autosummary * `#17404 `__: MAINT: Replace PyUString_ConcatAndDel in nditer_constr.c. * `#17405 `__: MAINT: Replace PyUString_ConcatAndDel in mapping.c. -* `#17406 `__: ENH: Replace the module-level `__getattr__` with explicit type... +* `#17406 `__: ENH: Replace the module-level ``__getattr__`` with explicit type... * `#17407 `__: DOC: in PR template, set expectations for PR review timeline * `#17409 `__: MAINT: Cleanup remaining PyUString_ConcatAndDel use. * `#17410 `__: API: Special case how numpy scalars are coerced to signed integer * `#17411 `__: TST: Mark the typing tests as slow -* `#17412 `__: DOC: Fix a parameter type in the `putmask` docs +* `#17412 `__: DOC: Fix a parameter type in the ``putmask`` docs * `#17418 `__: DOC: adding operational form documentation for array ops * `#17419 `__: DEP: Deprecate coercion to subarray dtypes * `#17421 `__: BUG: Fix memory leak in array-coercion error paths @@ -674,7 +703,7 @@ A total of 684 pull requests were merged for this release. * `#17423 `__: DOC: Remove bogus reference to _a_ * `#17424 `__: DOC: Fix formatting issues in description of .c.src files * `#17427 `__: NEP: nep-0029 typo correction -* `#17429 `__: MAINT: Move aliases for common scalar unions to `numpy.typing` +* `#17429 `__: MAINT: Move aliases for common scalar unions to ``numpy.typing`` * `#17430 `__: BUG: Fix memoryleaks related to NEP 37 function overrides * `#17431 `__: DOC: Fix the links for ``Ellipsis`` * `#17432 `__: DOC: add references to einops and opt_einsum @@ -685,7 +714,7 @@ A total of 684 pull requests were merged for this release. * `#17440 `__: DOC: Cleaner template for PRs * `#17442 `__: MAINT: fix exception chaining in format.py * `#17443 `__: ENH: Warn on unsupported Python 3.10+ -* `#17444 `__: ENH: Add `Typing :: Typed` to the PyPi classifier +* `#17444 `__: ENH: Add ``Typing :: Typed`` to the PyPi classifier * `#17445 `__: DOC: Fix the references for macros * `#17447 `__: NEP: update NEP 42 with discussion of type hinting applications * `#17448 `__: DOC: Remove CoC pages from Sphinx @@ -699,16 +728,17 @@ A total of 684 pull requests were merged for this release. * `#17468 `__: DOC: add some missing scalar aliases * `#17472 `__: TST: Fix doctest for full_like * `#17473 `__: MAINT: py3k: remove os.fspath and os.PathLike backports -* `#17474 `__: MAINT: Move the `np.core.numeric` annotations to their own stub... -* `#17479 `__: ENH: type np.unicode_ as np.str_ +* `#17474 `__: MAINT: Move the ``np.core.numeric`` annotations to their own stub... +* `#17479 `__: ENH: type ``np.unicode_`` as ``np.str_`` * `#17481 `__: DOC: Fix the entries for members of structures -* `#17483 `__: DOC: Fix the references for `random.*` +* `#17483 `__: DOC: Fix the references for ``random.*`` * `#17485 `__: BLD: circleCI- merge before build, add -n to sphinx * `#17487 `__: MAINT: Remove duplicate placeholder annotations +* `#17493 `__: DOC: New round of NEP 42 edits * `#17497 `__: DOC: Use consistent lowercase on docs landing page * `#17498 `__: MAINT: fix incompatible type comparison in numpy.lib.utils.info * `#17501 `__: BUG: Fix failures in master related to userdtype registeration -* `#17502 `__: BUG: remove `sys` from the type stubs +* `#17502 `__: BUG: remove ``sys`` from the type stubs * `#17503 `__: DOC: Fix empty 'C style guide' page * `#17504 `__: DOC: Rename 'Quickstart tutorial' * `#17508 `__: ENH: Added the Final feature for all constants @@ -726,15 +756,15 @@ A total of 684 pull requests were merged for this release. * `#17537 `__: MAINT: Bump hypothesis from 5.37.0 to 5.37.1 * `#17538 `__: MAINT: Bump pydata-sphinx-theme from 0.4.0 to 0.4.1 * `#17539 `__: MAINT: Bump mypy from 0.782 to 0.790 -* `#17540 `__: ENH: Make `np.number` generic with respect to its precision +* `#17540 `__: ENH: Make ``np.number`` generic with respect to its precision * `#17541 `__: CI: fix conditional for PR merge command -* `#17546 `__: MAINT: explicit disabling `CCompilerOpt` in F2PY +* `#17546 `__: MAINT: explicit disabling ``CCompilerOpt`` in F2PY * `#17548 `__: BUG: Cygwin Workaround for #14787 on affected platforms * `#17549 `__: DOC: Fix the entries of C functions * `#17555 `__: DOC: Fix wrong blockquotes * `#17558 `__: DOC: MAINT: Add NEP 43 links to NEP 42 * `#17559 `__: DOC: Remove directives for some constants -* `#17564 `__: MAINT: Update the annotations in `np.core.numeric` +* `#17564 `__: MAINT: Update the annotations in ``np.core.numeric`` * `#17570 `__: DOC: Add the entry for ``NPY_FEATURE_VERSION`` * `#17571 `__: DOC: Fix typos * `#17572 `__: ENH: Add annotations for three new constants @@ -742,27 +772,27 @@ A total of 684 pull requests were merged for this release. * `#17577 `__: BUG: Respect dtype of all-zero argument to poly1d * `#17578 `__: NEP36: include additional feedback * `#17580 `__: MAINT: Cleanup swig for Python 3. -* `#17581 `__: MAINT: Move the `np.core.numerictypes` annotations to their own... +* `#17581 `__: MAINT: Move the ``np.core.numerictypes`` annotations to their own... * `#17583 `__: MAINT: Bump hypothesis from 5.37.1 to 5.37.3 -* `#17584 `__: ENH: Add annotations for `np.core._type_aliases` +* `#17584 `__: ENH: Add annotations for ``np.core._type_aliases`` * `#17594 `__: DOC: Typo in lexsort docstring * `#17596 `__: DEP,BUG: Coercion/cast of array to a subarray dtype will be fixed * `#17597 `__: TST: Clean up the errors of the typing tests * `#17598 `__: BUG: Fixed file handle leak in array_tofile. -* `#17601 `__: TST: Fix a broken `np.core.numeric` test +* `#17601 `__: TST: Fix a broken ``np.core.numeric`` test * `#17603 `__: MAINT: Mark dead code as intentional for clang. * `#17607 `__: DOC: removed old references to submodule licenses * `#17608 `__: DOC: Fix typos (general documentation) * `#17610 `__: Fully qualify license trove classifier * `#17611 `__: BUG: mac dylib treated as part of extra objects by f2py -* `#17613 `__: ENH: Add annotations for 9 `ndarray`/`generic` magic methods +* `#17613 `__: ENH: Add annotations for 9 ``ndarray``/``generic`` magic methods * `#17614 `__: DOC: Fix the document for arrays interface * `#17618 `__: MAINT: Conversion of some strings to f-strings * `#17619 `__: DOC: Fix some references * `#17621 `__: TST: Valid docstring for config_py function show() * `#17622 `__: MAINT: Conversion of some strings to fstrings, part II * `#17623 `__: MAINT: Conversion of some strings to fstrings, part III -* `#17624 `__: DOC: Tidy up references to str_ / bytes_ +* `#17624 `__: DOC: Tidy up references to ``str_`` / ``bytes_`` * `#17625 `__: MAINT: Conversion of some strings to fstrings, part iv * `#17627 `__: DOC: Fix the references for ``__array_*__`` * `#17628 `__: DOC: Add entries for macros @@ -773,8 +803,8 @@ A total of 684 pull requests were merged for this release. * `#17639 `__: MAINT: Bump hypothesis from 5.37.3 to 5.38.0 * `#17641 `__: MAINT, BLD: update to OpenBLAS v0.3.12 * `#17642 `__: DOC: Fix reference to atleast_1d -* `#17643 `__: ENH: Add annotations for `np.core._ufunc_config` -* `#17644 `__: ENH: Add annotations for `np.core.shape_base` +* `#17643 `__: ENH: Add annotations for ``np.core._ufunc_config`` +* `#17644 `__: ENH: Add annotations for ``np.core.shape_base`` * `#17645 `__: BUG: fix np.timedelta64('nat').__format__ throwing an exception * `#17654 `__: BUG: f2py incorrectly translates dimension declarations. * `#17655 `__: BLD: Fix installing Numpy on z/OS @@ -799,7 +829,9 @@ A total of 684 pull requests were merged for this release. * `#17700 `__: Fix small typos. * `#17701 `__: BUG: Fixed an issue where ``.pyi`` files were ignored by numpy... * `#17703 `__: Fix Doc Typos & Added Example +* `#17706 `__: BUG: Raise promotion error if a DType was provided in array coercion * `#17708 `__: Improve the einsum bench by adding new bench cases and variable... +* `#17711 `__: ENH: adds type hints to numpy.version * `#17715 `__: REV: Revert gh-17654 - f2py incorrectly translates dimension... * `#17717 `__: MAINT: Add more files to ``.gitgnore`` * `#17720 `__: API: Do not import sliding_window_view to main namespace @@ -836,9 +868,9 @@ A total of 684 pull requests were merged for this release. * `#17830 `__: TST: Add back durations flag for DEBUG builds. * `#17832 `__: BUG: Fix subarray dtype used with too large count in fromfile * `#17833 `__: BUG: Fix pickling of scalars with NPY_LISTPICKLE -* `#17838 `__: DOC: Update the `numpy.typing` documentation +* `#17838 `__: DOC: Update the ``numpy.typing`` documentation * `#17841 `__: DOC: Fixing boilerplate code example -* `#17844 `__: MAINT: Add ``__all__`` to `numpy.typing` +* `#17844 `__: MAINT: Add ``__all__`` to ``numpy.typing`` * `#17848 `__: DOC: Add release note for gh-16161. * `#17855 `__: BUG: Fix incorrect C function prototypes/declarations. * `#17857 `__: MAINT: Prepare for the NumPy 1.20.x branch. From 608c8935a9a88293514ca4e71f86198d60865131 Mon Sep 17 00:00:00 2001 From: Charles Harris Date: Fri, 7 May 2021 09:16:35 -0600 Subject: [PATCH 28/33] DOC: Update 1.19.0-changelog.rst. --- doc/changelog/1.19.0-changelog.rst | 100 ++++++++++++++++++++--------- 1 file changed, 68 insertions(+), 32 deletions(-) diff --git a/doc/changelog/1.19.0-changelog.rst b/doc/changelog/1.19.0-changelog.rst index bd743832a33b..bde00249972a 100644 --- a/doc/changelog/1.19.0-changelog.rst +++ b/doc/changelog/1.19.0-changelog.rst @@ -136,25 +136,28 @@ names contributed a patch for the first time. Pull requests merged ==================== -A total of 452 pull requests were merged for this release. +A total of 488 pull requests were merged for this release. * `#8255 `__: ENH: add identity kwarg to frompyfunc +* `#10600 `__: DOC: Do not complain about contiguity when mutating ``ndarray.shape`` * `#12646 `__: TST: check exception details in refguide_check.py * `#13421 `__: ENH: improve runtime detection of CPU features * `#14326 `__: TST: Add assert_array_equal test for big integer arrays. * `#14376 `__: MAINT: Remove unnecessary 'from __future__ import ...' statements * `#14530 `__: MAINT: Fix typos and copy edit NEP-0030. * `#14546 `__: DOC: NumPy for absolute beginners tutorial -* `#14715 `__: NEP: Proposal for array creation dispatching with `__array_function__` +* `#14715 `__: NEP: Proposal for array creation dispatching with ``__array_function__`` * `#14867 `__: ENH: Use AVX-512F for np.maximum and np.minimum * `#14924 `__: BUG: Fix numpy.random.dirichlet returns NaN for small 'alpha'... -* `#14933 `__: API: Use `ResultType` in `PyArray_ConvertToCommonType` +* `#14933 `__: API: Use ``ResultType`` in ``PyArray_ConvertToCommonType`` +* `#14940 `__: BUG: pickle the content of a scalar containing objects, not the... * `#14942 `__: MAINT,API: ignore and NULL fasttake/fastputmask ArrFuncs slots * `#14981 `__: BUG: Make ``ediff1d`` kwarg casting consistent * `#14988 `__: DOC: linalg: Include information about scipy.linalg. * `#14995 `__: BUG: Use ``__array__`` during dimension discovery * `#15011 `__: MAINT: cleanup compat.py3k.py * `#15022 `__: ENH: f2py: improve error messages +* `#15024 `__: DOC: clarify documentation for transpose() * `#15028 `__: [DOC] LaTeX: fix preamble (closes #15026) * `#15035 `__: BUG: add endfunction, endsubroutine to valid fortran end words * `#15040 `__: TST: Add test for object method (and general unary) loops @@ -165,6 +168,7 @@ A total of 452 pull requests were merged for this release. * `#15052 `__: MAINT: follow-up cleanup for blas64 PR * `#15054 `__: DOC: add docstrings to refguide-check * `#15066 `__: Revert "DEP: issue deprecation warning when creating ragged array... +* `#15068 `__: ENH: Add support to sort timedelta64 ``NaT`` to end of the array * `#15069 `__: ENH: add support for ILP64 OpenBLAS (without symbol suffix) * `#15070 `__: DOC: correct version for NaT sort * `#15072 `__: TST: Check requires_memory immediately before the test @@ -201,6 +205,7 @@ A total of 452 pull requests were merged for this release. * `#15187 `__: MAINT: unskip test on win32 * `#15189 `__: ENH: Add property-based tests using Hypothesis * `#15194 `__: BUG: test, fix for c++ compilation +* `#15195 `__: MAINT: refactoring in np.core.records * `#15196 `__: DOC: Adding instructions for building documentation to developer... * `#15197 `__: DOC: NEP 37: A dispatch protocol for NumPy-like modules * `#15203 `__: MAINT: Do not use private Python function in testing @@ -215,6 +220,8 @@ A total of 452 pull requests were merged for this release. * `#15227 `__: DOC: typo in release.rst * `#15228 `__: NEP: universal SIMD NEP 38 * `#15229 `__: MAINT: Remove unused int_asbuffer +* `#15230 `__: BUG: do not emit warnings for np.sign, np.equal when using nan +* `#15231 `__: MAINT: Remove Python2 specific C module setup [part2] * `#15232 `__: MAINT: Cleaning up PY_MAJOR_VERSION/PY_VERSION_HEX * `#15233 `__: MAINT: Clean up more PY_VERSION_HEX * `#15236 `__: MAINT: Remove implicit inheritance from object class @@ -224,14 +231,14 @@ A total of 452 pull requests were merged for this release. * `#15241 `__: MAINT: Remove references to non-existent sys.exc_clear() * `#15242 `__: DOC: Update HOWTO_RELEASE.rst * `#15248 `__: MAINT: cleanup use of sys.exc_info -* `#15249 `__: MAINT: Eliminate some calls to `eval` +* `#15249 `__: MAINT: Eliminate some calls to ``eval`` * `#15251 `__: MAINT: Improve const-correctness of shapes and strides * `#15253 `__: DOC: clarify the effect of None parameters passed to ndarray.view * `#15254 `__: MAINT: Improve const-correctness of string arguments * `#15255 `__: MAINT: Delete numpy.distutils.compat * `#15256 `__: MAINT: Implement keyword-only arguments as syntax * `#15260 `__: MAINT: Remove FIXME comments introduced in the previous commit -* `#15261 `__: MAINT: Work with unicode strings in `dtype('i8,i8')` +* `#15261 `__: MAINT: Work with unicode strings in ``dtype('i8,i8')`` * `#15262 `__: BUG: Use PyDict_GetItemWithError() instead of PyDict_GetItem() * `#15263 `__: MAINT: Remove python2 array_{get,set}slice * `#15264 `__: DOC: Add some missing functions in the list of available ufuncs. @@ -248,8 +255,9 @@ A total of 452 pull requests were merged for this release. * `#15280 `__: BENCH: Add basic benchmarks for take and putmask * `#15281 `__: MAINT: Cleanup most PY3K #ifdef guards * `#15282 `__: DOC: BLD: add empty release notes for 1.19.0 to fix doc build... +* `#15283 `__: MAINT: Cleanup more NPY_PY3K * `#15284 `__: MAINT: Use a simpler return convention for internal functions -* `#15285 `__: MAINT: Simplify np.int_ inheritance +* `#15285 `__: MAINT: Simplify ``np.int_`` inheritance * `#15286 `__: DOC" Update np.full docstring. * `#15287 `__: MAINT: Express PyArray_DescrAlignConverter in terms of _convert_from_any * `#15288 `__: MAINT: Push down declarations in _convert_from_* @@ -261,7 +269,7 @@ A total of 452 pull requests were merged for this release. * `#15304 `__: MAINT: Remove NPY_PY3K constant * `#15305 `__: MAINT: Remove sys.version checks in tests * `#15307 `__: MAINT: cleanup sys.version dependant code -* `#15310 `__: MAINT: Ensure `_convert_from_*` functions set errors +* `#15310 `__: MAINT: Ensure ``_convert_from_*`` functions set errors * `#15312 `__: MAINT: Avoid escaping unicode in error messages * `#15315 `__: MAINT: Change file extension of ma README to rst. * `#15319 `__: BUG: fix NameError in clip nan propagation tests @@ -271,22 +279,25 @@ A total of 452 pull requests were merged for this release. * `#15329 `__: TST: move _no_tracing to testing._private, remove testing.support * `#15333 `__: BUG: Add some missing C error handling * `#15335 `__: MAINT: Remove sys.version checks -* `#15336 `__: DEP: Deprecate `->f->fastclip` at registration time +* `#15336 `__: DEP: Deprecate ``->f->fastclip`` at registration time * `#15338 `__: DOC: document site.cfg.example * `#15350 `__: MAINT: Fix mistype in histogramdd docstring * `#15351 `__: DOC, BLD: reword release note, upgrade sphinx version * `#15353 `__: MAINT: Remove unnecessary calls to PyArray_DATA from binomial... * `#15354 `__: MAINT: Bump pytest from 5.3.2 to 5.3.3 +* `#15355 `__: MAINT: Const qualify UFunc inner loops * `#15358 `__: MAINT: Remove six * `#15361 `__: MAINT: Revise imports from collections.abc module * `#15362 `__: MAINT: remove internal functions required to handle Python2/3... * `#15364 `__: MAINT: Remove other uses of six module * `#15366 `__: MAINT: resolve pyflake F403 'from module import *' used +* `#15367 `__: DOC: Fix Multithreaded Generation example docs * `#15368 `__: MAINT: Update tox for supported Python versions * `#15369 `__: MAINT: simd: Avoid signed comparison warning -* `#15370 `__: DOC: Updating Chararry Buffer datatypes #15360 +* `#15370 `__: DOC: Updating Chararry Buffer datatypes +* `#15373 `__: MAINT: Remove sys.version checks * `#15374 `__: TST: Simplify unicode test -* `#15375 `__: MAINT: Use `with open` when possible +* `#15375 `__: MAINT: Use ``with open`` when possible * `#15377 `__: MAINT: Cleanup python2 references * `#15379 `__: MAINT: Python2 Cleanups * `#15381 `__: DEP: add PendingDeprecation to matlib.py funky namespace @@ -303,11 +314,14 @@ A total of 452 pull requests were merged for this release. * `#15407 `__: MAINT: Replace basestring with str. * `#15408 `__: ENH: Use AVX-512F for complex number arithmetic, absolute, square... * `#15414 `__: MAINT: Remove Python2 workarounds +* `#15415 `__: MAINT: Revert f2py Python 2.6 workaround * `#15417 `__: MAINT: Cleanup references to python2 * `#15418 `__: MAINT, DOC: Remove use of old Python __builtin__, now known as... * `#15421 `__: ENH: Make use of ExitStack in npyio.py * `#15422 `__: MAINT: Inline gentype_getreadbuf * `#15423 `__: MAINT: Use f-strings for clarity. +* `#15425 `__: MAINT: dir(numpy) returns duplicate "testing" +* `#15426 `__: MAINT: Use the PyArrayScalar_VAL macro where possible * `#15427 `__: DEP: Schedule unused C-API functions for removal/disabling * `#15428 `__: DOC: Improve ndarray.ctypes example * `#15429 `__: DOC: distutils: Add a docstring to show_config(). @@ -315,14 +329,15 @@ A total of 452 pull requests were merged for this release. * `#15434 `__: MAINT: Updated polynomial to use fstrings * `#15435 `__: DOC: Fix Incorrect document in Beginner Docs * `#15436 `__: MAINT: Update core.py with fstrings (issue #15420) -* `#15439 `__: DOC: fix docstrings so `python tools/refguide-check --rst ... +* `#15439 `__: DOC: fix docstrings so ``python tools/refguide-check --rst ``... * `#15441 `__: MAINT: Tidy macros in scalar_new * `#15444 `__: MAINT: use 'yield from ' for simple cases * `#15445 `__: MAINT: Bump pytest from 5.3.3 to 5.3.4 * `#15446 `__: BUG: Reject nonsense arguments to scalar constructors * `#15449 `__: DOC: Update refguide_check note on how to skip code -* `#15451 `__: MAINT: Simplify `np.object_.__new__` +* `#15451 `__: MAINT: Simplify ``np.object_.__new__`` * `#15452 `__: STY,MAINT: avoid 'multiple imports on one line' +* `#15463 `__: ENH: expose ``bit_generator`` and random C-API to cython * `#15464 `__: MAINT: Cleanup duplicate line in refguide_check * `#15465 `__: MAINT: cleanup unused imports; avoid redefinition of imports * `#15468 `__: BUG: Fix for SVD not always sorted with hermitian=True @@ -330,21 +345,22 @@ A total of 452 pull requests were merged for this release. * `#15474 `__: MAINT: Eliminate messy _WORK macro * `#15476 `__: update result of rng.random(3) to current rng output * `#15480 `__: DOC: Correct get_state doc -* `#15482 `__: MAINT: Use `.identifier = val` to fill type structs +* `#15482 `__: MAINT: Use ``.identifier = val`` to fill type structs * `#15483 `__: [DOC] Mention behaviour of np.squeeze with one element * `#15484 `__: ENH: fixing generic error messages to be more specific in multiarray/descriptor.c * `#15487 `__: BUG: Fixing result of np quantile edge case * `#15491 `__: TST: mark the top 3 slowest tests to save ~10 seconds * `#15493 `__: MAINT: Bump pytest from 5.3.4 to 5.3.5 * `#15500 `__: MAINT: Use True/False instead of 1/0 in np.dtype.__reduce__ -* `#15503 `__: MAINT: Do not allow `copyswap` and friends to fail silently +* `#15503 `__: MAINT: Do not allow ``copyswap`` and friends to fail silently * `#15504 `__: DOC: Remove duplicated code in true_divide docstring * `#15505 `__: NEP 40: Informational NEP about current DTypes +* `#15506 `__: NEP 41: First steps towards improved Datatype Support * `#15510 `__: DOC: Update unique docstring example * `#15511 `__: MAINT: Large overhead in some random functions * `#15516 `__: TST: Fix missing output in refguide-check * `#15521 `__: MAINT: Simplify arraydescr_richcompare -* `#15522 `__: MAINT: Fix internal misuses of `NPY_TITLE_KEY` +* `#15522 `__: MAINT: Fix internal misuses of ``NPY_TITLE_KEY`` * `#15524 `__: DOC: Update instructions for building/archiving docs. * `#15526 `__: BUG: Fix inline assembly that detects cpu features on x86(32bit) * `#15532 `__: update doctests, small bugs and changes of repr @@ -354,13 +370,15 @@ A total of 452 pull requests were merged for this release. * `#15543 `__: NEP: edit and move NEP 38 to accepted status * `#15547 `__: MAINT: Refresh Doxyfile and modernize numpyfilter.py * `#15549 `__: TST: Accuracy test float32 sin/cos/exp/log for AVX platforms -* `#15550 `__: DOC: Improve the `numpy.linalg.eig` docstring. +* `#15550 `__: DOC: Improve the ``numpy.linalg.eig`` docstring. +* `#15553 `__: BUG: Added missing error check in ``ndarray.__contains__`` * `#15554 `__: NEP 44 - Restructuring the NumPy Documentation * `#15556 `__: TST: (Travis CI) Use full python3-dbg path for virtual env creation * `#15560 `__: BUG, DOC: restore missing import * `#15566 `__: DOC: Removing bad practices from quick start + some PEP8 * `#15574 `__: TST: Do not create symbolic link named gfortran. * `#15575 `__: DOC: Document caveat in random.uniform +* `#15577 `__: TST: Test division by zero both with scalar and with array * `#15579 `__: DOC: numpy.clip is equivalent to minimum(..., maximum(...)) * `#15582 `__: MAINT: Bump cython from 0.29.14 to 0.29.15 * `#15583 `__: MAINT: Bump hypothesis from 5.3.0 to 5.5.4 @@ -369,6 +387,7 @@ A total of 452 pull requests were merged for this release. * `#15600 `__: TST: use manylinux2010 docker instead of ubuntu * `#15610 `__: TST: mask DeprecationWarning in xfailed test * `#15612 `__: BUG: Fix bug in AVX-512F np.maximum and np.minimum +* `#15614 `__: DOC: Reword docstring for assert_equal * `#15615 `__: BUG: Remove check requiring natural alignment of float/double... * `#15616 `__: DOC: Add missing imports, definitions and dummy file * `#15619 `__: DOC: Fix documentation for apply_along_axis @@ -376,9 +395,10 @@ A total of 452 pull requests were merged for this release. * `#15631 `__: MAINT: Pull identical line out of conditional. * `#15633 `__: DOC: remove broken link in f2py tutorial * `#15639 `__: BLD: update openblas download to new location, use manylinux2010-base +* `#15644 `__: DOC: Update to clarify actual behavior real_if_(all elements)_close * `#15648 `__: MAINT: AVX512 implementation with intrinsic for float64 input... * `#15653 `__: BLD: update OpenBLAS to pre-0.3.9 version -* `#15662 `__: DOC: Refactor `np.polynomial` docs using `automodule` +* `#15662 `__: DOC: Refactor ``np.polynomial`` docs using ``automodule`` * `#15665 `__: BUG: fix doctest exception messages * `#15672 `__: MAINT: Added comment pointing FIXME to relevant PR. * `#15673 `__: DOC: Make extension module wording more clear @@ -386,16 +406,18 @@ A total of 452 pull requests were merged for this release. * `#15680 `__: DOC: Improve Benchmark README with environment setup and more... * `#15682 `__: MAINT: Bump hypothesis from 5.5.4 to 5.6.0 * `#15683 `__: NEP: move NEP 44 to accepted status +* `#15685 `__: ENH: Add ``subok`` parameter to np.copy function (cf. #6509) * `#15694 `__: DOC: Fix indexing docs to pass refguide * `#15695 `__: MAINT: Test during import to detect bugs with Accelerate(MacOS)... * `#15696 `__: MAINT: Add a fast path to var for complex input * `#15701 `__: MAINT: Convert shebang from python to python3 (#15687) * `#15702 `__: MAINT: replace optparse with argparse for 'doc' and 'tools' scripts * `#15703 `__: DOC: Fix quickstart doc to pass refguide +* `#15705 `__: DOC: Change list to tuple in example description. * `#15706 `__: MAINT: Fixing typos in f2py comments and code. * `#15710 `__: DOC: fix SVD tutorial to pass refguide * `#15714 `__: MAINT: use list-based APIs to call subprocesses -* `#15715 `__: ENH: update numpy.linalg.multi_dot to accept an `out` argument +* `#15715 `__: ENH: update numpy.linalg.multi_dot to accept an ``out`` argument * `#15716 `__: TST: always use 'python -mpip' not 'pip' * `#15717 `__: DOC: update datetime reference to pass refguide * `#15718 `__: DOC: Fix coremath.rst to fix refguide_check @@ -403,6 +425,7 @@ A total of 452 pull requests were merged for this release. * `#15723 `__: BUG: fix logic error when nm fails on 32-bit * `#15724 `__: TST: Remove nose from the test_requirements.txt file. * `#15733 `__: DOC: Allow NEPs to link to python, numpy, scipy, and matplotlib... +* `#15735 `__: DOC: LICENSE 2019 -> 2020 * `#15736 `__: BUG: Guarantee array is in valid state after memory error occurs... * `#15738 `__: MAINT: Remove non-native byte order from _var check. * `#15740 `__: MAINT: Add better error handling in linalg.norm for vectors and... @@ -418,28 +441,30 @@ A total of 452 pull requests were merged for this release. * `#15769 `__: ENH: Allow toggling madvise hugepage and fix default * `#15771 `__: DOC: Fix runtests example in developer docs * `#15773 `__: DEP: Make issubdtype consistent for types and dtypes -* `#15774 `__: MAINT: remove useless `global` statements +* `#15774 `__: MAINT: remove useless ``global`` statements * `#15778 `__: BLD: Add requirements.txt file for building docs * `#15781 `__: BUG: don't add 'public' or 'private' if the other one exists -* `#15784 `__: ENH: Use TypeError in `np.array` for python consistency +* `#15784 `__: ENH: Use TypeError in ``np.array`` for python consistency * `#15794 `__: BUG: Add basic __format__ for masked element to fix incorrect... * `#15797 `__: TST: Add unit test for out=None of np.einsum * `#15799 `__: MAINT: Cleanups to np.insert and np.delete * `#15800 `__: BUG: Add error-checking versions of strided casts. -* `#15802 `__: DEP: Make `np.insert` and `np.delete` on 0d arrays with an axis... -* `#15803 `__: DOC: correct possible list lengths for `extobj` in ufunc calls +* `#15802 `__: DEP: Make ``np.insert`` and ``np.delete`` on 0d arrays with an axis... +* `#15803 `__: DOC: correct possible list lengths for ``extobj`` in ufunc calls * `#15804 `__: DEP: Make np.delete on out-of-bounds indices an error -* `#15805 `__: DEP: Forbid passing non-integral index arrays to `insert` and... +* `#15805 `__: DEP: Forbid passing non-integral index arrays to ``insert`` and... * `#15806 `__: TST: Parametrize sort test * `#15809 `__: TST: switch PyPy job with CPython * `#15812 `__: TST: Remove code that is not supposed to warn out of warning... * `#15815 `__: DEP: Do not cast boolean indices to integers in np.delete * `#15816 `__: MAINT: simplify code that assumes str/unicode and int/long are... +* `#15827 `__: BUG: Break on all errors when performing strided casts. * `#15830 `__: MAINT: pathlib and hashlib are in stdlib in Python 3.5+ -* `#15832 `__: ENH: improved error message `IndexError: too many indices for... +* `#15832 `__: ENH: improved error message ``IndexError: too many indices for``... +* `#15834 `__: NEP: Add paragraph to NEP 41 about no array-object use and fix... * `#15836 `__: BUG: Fix IndexError for illegal axis in np.mean * `#15839 `__: DOC: Minor fix to _hist_bin_fd documentation -* `#15840 `__: BUG,DEP: Make `scalar.__round__()` behave like pythons round +* `#15840 `__: BUG,DEP: Make ``scalar.__round__()`` behave like pythons round * `#15843 `__: DOC: First steps towards docs restructuring (NEP 44) * `#15848 `__: DOC, TST: enable refguide_check in circleci * `#15850 `__: DOC: fix typo in C-API reference @@ -447,8 +472,9 @@ A total of 452 pull requests were merged for this release. * `#15866 `__: MAINT: Bump cython from 0.29.15 to 0.29.16 * `#15867 `__: DEP: Deprecate ndarray.tostring() * `#15868 `__: TST: use draft OpenBLAS build +* `#15870 `__: ENH: Add keepdims argument to count_nonzero * `#15872 `__: BUG: Fix eigh and cholesky methods of numpy.random.multivariate_normal -* `#15876 `__: BUG: Check that `pvals` is 1D in `_generator.multinomial`. +* `#15876 `__: BUG: Check that ``pvals`` is 1D in ``_generator.multinomial``. * `#15877 `__: DOC: Add missing signature from nditer docstring * `#15881 `__: BUG: Fix empty_like to respect shape=() * `#15882 `__: BUG: Do not ignore empty tuple of strides in ndarray.__new__ @@ -456,29 +482,34 @@ A total of 452 pull requests were merged for this release. * `#15884 `__: BUG: Setting a 0d array's strides to themselves should be legal * `#15885 `__: BUG: Respect itershape=() in nditer * `#15887 `__: MAINT: Clean-up 'next = __next__' used for Python 2 compatibility +* `#15891 `__: DOC: Clarify docs on mixed advanced indexing and slicing * `#15893 `__: TST: Run test_large_zip in a child process * `#15894 `__: DOC: Add missing doc of numpy.ma.apply_over_axes in API list. * `#15899 `__: DOC: Improve record module documentation * `#15901 `__: DOC: Fixed order of items and link to mailing list in dev docs... * `#15903 `__: BLD: report clang version on macOS -* `#15904 `__: MAINT: records: Remove private `format_parser._descr` attribute +* `#15904 `__: MAINT: records: Remove private ``format_parser._descr`` attribute +* `#15907 `__: DOC: Update documentation w.r.t. NPY_RELAXED_STRIDES_CHECKING * `#15914 `__: BUG: random: Disallow p=0 in negative_binomial +* `#15920 `__: DOC: Improve docstring for numpy.linalg.lstsq * `#15921 `__: ENH: Use sysconfig instead of probing Makefile * `#15928 `__: DOC: Update np.copy docstring to include ragged case * `#15931 `__: DOC: Correct private function name to PyArray_AdaptFlexibleDType -* `#15936 `__: MAINT: Fix capitalization in error message in `mtrand.pyx` +* `#15936 `__: MAINT: Fix capitalization in error message in ``mtrand.pyx`` +* `#15938 `__: BUG: Add _LARGE_FILES to def_macros[] when platform is AIX. * `#15939 `__: DOC: Update np.rollaxis docstring * `#15949 `__: BUG: fix AttributeError on accessing object in nested MaskedArray. -* `#15951 `__: BUG: Alpha parameter must be 1D in `generator.dirichlet` +* `#15951 `__: BUG: Alpha parameter must be 1D in ``generator.dirichlet`` * `#15953 `__: NEP: minor maintenance, update filename and fix a cross-reference * `#15964 `__: MAINT: Bump hypothesis from 5.8.0 to 5.8.3 * `#15967 `__: TST: Add slow_pypy support * `#15968 `__: DOC: Added note to angle function docstring about angle(0) being... * `#15982 `__: MAINT/BUG: Cleanup and minor fixes to conform_reduce_result -* `#15985 `__: BUG: Avoid duplication in stack trace of `linspace(a, b, num=1.5)` -* `#15988 `__: BUG: Fix inf and NaN-warnings in half float `nextafter` +* `#15985 `__: BUG: Avoid duplication in stack trace of ``linspace(a, b, num=1.5)`` +* `#15988 `__: BUG: Fix inf and NaN-warnings in half float ``nextafter`` * `#15989 `__: MAINT: Remove 0d check for PyArray_ISONESEGMENT * `#15990 `__: DEV: Pass additional runtests.py args to ASV +* `#15991 `__: BUG: max/min of a masked array dtype fix * `#15993 `__: DOC: Fix method documentation of function sort in MaskedArray * `#16000 `__: NEP: Improve Value Based Casting paragraph in NEP 40 * `#16001 `__: DOC: add note on flatten ordering in matlab page @@ -496,6 +527,8 @@ A total of 452 pull requests were merged for this release. * `#16038 `__: MAINT,TST: Move _repr_latex tests to test_printing. * `#16041 `__: BUG: missing 'f' prefix for fstring * `#16042 `__: ENH: Fix exception causes in build_ext.py +* `#16043 `__: DOC: Add converters example to the loadtxt docstring +* `#16051 `__: DOC: Add missing bracket * `#16053 `__: DOC: Small typo fixes to NEP 40. * `#16054 `__: DOC, BLD: update release howto and walkthrough for ananconda.org... * `#16061 `__: ENH: Chained exceptions in linalg.py and polyutils.py @@ -508,6 +541,7 @@ A total of 452 pull requests were merged for this release. * `#16077 `__: BLD: fix path to libgfortran on macOS * `#16078 `__: DOC: Add axis to random module "new or different" docs * `#16079 `__: DOC,BLD: Limit timeit iterations in random docs. +* `#16080 `__: BUG: numpy.einsum indexing arrays now accept numpy int type * `#16081 `__: DOC: add note on type casting to numpy.left_shift(). * `#16083 `__: DOC: improve development debugging doc * `#16084 `__: DOC: tweak neps/scope.rst @@ -517,10 +551,12 @@ A total of 452 pull requests were merged for this release. * `#16097 `__: MAINT, DOC: Improve grammar on a comment in the quickstart * `#16100 `__: NEP 41: Accept NEP 41 and add DType<->scalar duplication paragraph * `#16101 `__: BLD: put openblas library in local directory on windows +* `#16102 `__: ENH: correct identity for logaddexp2 ufunc: -inf * `#16113 `__: MAINT: Fix random.PCG64 signature * `#16119 `__: DOC: Move misplaced news fragment for gh-13421 * `#16122 `__: DOC: Fix links for NEP 40 in NEP 41 * `#16125 `__: BUG: lib: Fix a problem with vectorize with default parameters. +* `#16128 `__: ENH: Add equal_nan keyword argument to array_equal * `#16129 `__: ENH: Better error message when ``bins`` has float value in ``histogramdd``. * `#16133 `__: MAINT: Unify casting error creation (outside the iterator) * `#16141 `__: BENCH: Default to building HEAD instead of master @@ -571,7 +607,7 @@ A total of 452 pull requests were merged for this release. * `#16344 `__: BUG: Allow attaching documentation twice in add_docstring * `#16355 `__: MAINT: Remove f-strings in setup.py. (gh-16346) * `#16356 `__: BUG: Indentation for docstrings -* `#16358 `__: BUG: Fix dtype leak in `PyArray_FromAny` error path +* `#16358 `__: BUG: Fix dtype leak in ``PyArray_FromAny`` error path * `#16383 `__: ENH: Optimize Cpu feature detect in X86, fix for GCC on macOS... * `#16398 `__: MAINT: core: Use a raw string for the fromstring docstring. * `#16399 `__: MAINT: Make ctypes optional on Windows From ce397dea6553bf92ef983e59db183fec3cf31807 Mon Sep 17 00:00:00 2001 From: Charles Harris Date: Fri, 7 May 2021 09:35:08 -0600 Subject: [PATCH 29/33] DOC: Update 1.18.0-changelog.rst. --- doc/changelog/1.18.0-changelog.rst | 55 +++++++++++++++++------------- 1 file changed, 31 insertions(+), 24 deletions(-) diff --git a/doc/changelog/1.18.0-changelog.rst b/doc/changelog/1.18.0-changelog.rst index b86b3614ad3a..266ff08077ac 100644 --- a/doc/changelog/1.18.0-changelog.rst +++ b/doc/changelog/1.18.0-changelog.rst @@ -123,20 +123,20 @@ names contributed a patch for the first time. Pull requests merged ==================== -A total of 406 pull requests were merged for this release. +A total of 413 pull requests were merged for this release. * `#9301 `__: DOC: added note to docstring of numpy.savez * `#10151 `__: BUG: Numpy scalar types sometimes have the same name * `#12129 `__: DOC: Improve axes shift description and example in np.tensordot -* `#12205 `__: MAINT: avoid relying on `np.generic.__name__` in `np.dtype.name` +* `#12205 `__: MAINT: avoid relying on ``np.generic.__name__`` in ``np.dtype.name`` * `#12284 `__: ENH: supply our version of numpy.pxd, requires cython>=0.29 * `#12633 `__: BUG: General fixes to f2py reference counts (dereferencing) * `#12658 `__: BUG: NaT now sorts to ends of arrays * `#12828 `__: DOC: Updates to nditer usage instructions -* `#13003 `__: BUG: Do not crash on recursive `.dtype` attribute lookup. +* `#13003 `__: BUG: Do not crash on recursive ``.dtype`` attribute lookup. * `#13368 `__: ENH: Use AVX for float32 implementation of np.sin & np.cos * `#13605 `__: DEP: Deprecate silent ignoring of bad data in fromfile/fromstring -* `#13610 `__: ENH: Always produce a consistent shape in the result of `argwhere` +* `#13610 `__: ENH: Always produce a consistent shape in the result of ``argwhere`` * `#13673 `__: DOC: array(obj, dtype=dt) can downcast * `#13698 `__: DOC: Document ma.filled behavior with non-scalar fill_value * `#13710 `__: DOC: Add note to irfft-like functions about the default sizes @@ -144,6 +144,7 @@ A total of 406 pull requests were merged for this release. * `#13766 `__: MAINT: Update NEP template. * `#13794 `__: ENH: random: Add the multivariate hypergeometric distribution. * `#13799 `__: DOC: Fix unrendered links +* `#13802 `__: BUG: Fixed maximum relative error reporting in assert_allclose * `#13812 `__: MAINT: Rewrite Floyd algorithm * `#13825 `__: DOC: Add missing macros to C-API documentation * `#13829 `__: ENH: Add axis argument to random.permutation and random.shuffle @@ -162,6 +163,7 @@ A total of 406 pull requests were merged for this release. * `#13892 `__: DOC : Refactor Array API documentation -- Array Structure and... * `#13895 `__: DOC: Fix typo in "make_mask" documentation * `#13896 `__: MAINT: Delete unused _aliased_types.py +* `#13899 `__: MAINT: Change the type of error raised in set_printoptions * `#13901 `__: BLD: Remove Trusty dist in Travis CI build * `#13907 `__: BUG: Handle weird bytestrings in dtype() * `#13908 `__: ENH: use towncrier to build the release note @@ -174,7 +176,7 @@ A total of 406 pull requests were merged for this release. * `#13926 `__: DOC: Remove explicit .next method calls with built-in next function... * `#13928 `__: DOC: Don't override MaskedArray.view documentation with the one... * `#13930 `__: BUG: Fix incorrect GIL release in array.nonzero -* `#13935 `__: MAINT: Warn if `_add_newdocs.py` is used to add docstrings to... +* `#13935 `__: MAINT: Warn if ``_add_newdocs.py`` is used to add docstrings to... * `#13943 `__: MAINT: Revert #13876, "MAINT,BUG,DOC: Fix errors in _add_newdocs" * `#13944 `__: MAINT,BUG,DOC: Fix errors in _add_newdocs * `#13945 `__: DOC, MAINT: emphasize random API changes, remove Generator.randint @@ -184,7 +186,7 @@ A total of 406 pull requests were merged for this release. * `#13950 `__: Fixing failure on Python 2.7 on Windows 7 * `#13952 `__: Fix a typo related to the range of indices * `#13959 `__: DOC: add space between words across lines -* `#13964 `__: BUG, DOC: add new recfunctions to `__all__` +* `#13964 `__: BUG, DOC: add new recfunctions to ``__all__`` * `#13967 `__: DOC: Change (old) range() to np.arange() * `#13968 `__: DOC: improve np.sort docstring * `#13970 `__: DOC: spellcheck numpy/doc/broadcasting.py @@ -226,7 +228,7 @@ A total of 406 pull requests were merged for this release. * `#14076 `__: TST: Add 3.8-dev to travisCI testing. * `#14085 `__: DOC: Add blank line above doctest for intersect1d * `#14086 `__: ENH: Propose standard policy for dropping support of old Python... -* `#14089 `__: DOC: Use `pip install .` where possible instead of calling setup.py +* `#14089 `__: DOC: Use ``pip install .`` where possible instead of calling setup.py * `#14091 `__: MAINT: adjustments to test_ufunc_noncontigous * `#14092 `__: MAINT: Improve NEP template * `#14096 `__: DOC: fix documentation of i and j for tri. @@ -236,6 +238,7 @@ A total of 406 pull requests were merged for this release. * `#14106 `__: MAINT: remove duplicate variable assignments * `#14108 `__: BUG: initialize variable that is passed by pointer * `#14110 `__: DOC: fix typo in c-api/array.rst doc +* `#14115 `__: DOC: fix markup of news fragment readme * `#14121 `__: BUG: Add gcd/lcm definitions to npy_math.h * `#14122 `__: MAINT: Mark umath accuracy test xfail. * `#14124 `__: MAINT: Use equality instead of identity check with literal @@ -249,36 +252,39 @@ A total of 406 pull requests were merged for this release. * `#14153 `__: TST: Allow fuss in testing strided/non-strided exp/log loops * `#14170 `__: NEP: Proposal for __duckarray__ protocol * `#14171 `__: BUG: Make advanced indexing result on read-only subclass writeable +* `#14174 `__: BUG: Check for existence of ``fromstr`` which used in ``fromstr_next_element`` * `#14178 `__: TST: Clean up of test_pocketfft.py * `#14181 `__: DEP: Deprecate np.alen +* `#14183 `__: DOC: Fix misleading ``allclose`` docstring for ``equal_nan`` * `#14185 `__: MAINT: Workaround for Intel compiler bug leading to failing test -* `#14190 `__: DOC: Fix hermitian argument docs in `svd` +* `#14190 `__: DOC: Fix hermitian argument docs in ``svd`` * `#14195 `__: MAINT: Fix a docstring typo. -* `#14196 `__: DOC: Fix links in `/.github/CONTRIBUTING.md`. +* `#14196 `__: DOC: Fix links in ``/.github/CONTRIBUTING.md``. * `#14197 `__: ENH: Multivariate normal speedups * `#14203 `__: MAINT: Improve mismatch message of np.testing.assert_array_equal * `#14204 `__: DOC,MAINT: Move towncrier files and fixup categories * `#14207 `__: BUG: Fixed default BitGenerator name * `#14209 `__: BUG: Fix uint-overflow if padding with linear_ramp and negative... * `#14216 `__: ENH: Enable huge pages in all Linux builds -* `#14217 `__: BUG: Fix leak in the f2py-generated module init and `PyMem_Del`... +* `#14217 `__: BUG: Fix leak in the f2py-generated module init and ``PyMem_Del``... * `#14219 `__: DOC: new nan_to_num keywords are from 1.17 onwards * `#14223 `__: TST: Add tests for deprecated C functions (PyArray_As1D, PyArray_As1D) -* `#14224 `__: DOC: mention `take_along_axis` in `choose` +* `#14224 `__: DOC: mention ``take_along_axis`` in ``choose`` * `#14227 `__: ENH: Parse complex number from string * `#14231 `__: DOC: update or remove outdated sourceforge links * `#14234 `__: MAINT: Better error message for norm * `#14235 `__: DOC: add backlinks to numpy.org * `#14240 `__: BUG: Don't fail when lexsorting some empty arrays. -* `#14241 `__: BUG: Fix segfault in `random.permutation(x)` when x is a string. +* `#14241 `__: BUG: Fix segfault in ``random.permutation(x)`` when x is a string. * `#14245 `__: Doc: fix a typo in NEP21 * `#14249 `__: DOC: set status of NEP 28 (website redesign) to Accepted * `#14250 `__: BLD: MAINT: change default behavior of build flag appending. * `#14252 `__: BUG: Fixes StopIteration error from 'np.genfromtext' for empty... -* `#14255 `__: BUG: fix inconsistent axes ordering for axis in function `unique` +* `#14255 `__: BUG: fix inconsistent axes ordering for axis in function ``unique`` * `#14256 `__: DEP: Deprecate load/dump functions in favour of pickle methods * `#14257 `__: MAINT: Update NEP-30 * `#14259 `__: DEP: Deprecate arrayprint formatting functions +* `#14263 `__: DOC: Make Py3K docs C code snippets RST literal blocks * `#14266 `__: DOC: remove scipy.org from the breadcrumb formattiong * `#14270 `__: BUG: Fix formatting error in exception message * `#14272 `__: DOC: Address typos in dispatch docs @@ -293,9 +299,9 @@ A total of 406 pull requests were merged for this release. * `#14313 `__: DOC: Clarify rules about broadcasting when empty arrays are involved. * `#14321 `__: TST, MAINT: bump to OpenBLAS 0.3.7 stable * `#14325 `__: DEP: numpy.testing.rand -* `#14335 `__: DEP: Deprecate class `SafeEval` +* `#14335 `__: DEP: Deprecate class ``SafeEval`` * `#14341 `__: BUG: revert detecting and raising error on ragged arrays -* `#14342 `__: DOC: Improve documentation of `isscalar`. +* `#14342 `__: DOC: Improve documentation of ``isscalar``. * `#14349 `__: MAINT: Fix bloated mismatch error percentage in array comparisons. * `#14351 `__: DOC: Fix a minor typo in dispatch documentation. * `#14352 `__: MAINT: Remove redundant deprecation checks @@ -344,7 +350,7 @@ A total of 406 pull requests were merged for this release. * `#14475 `__: DOC: add timedelta64 signature * `#14477 `__: MAINT: Extract raising of MemoryError to a helper function * `#14483 `__: BUG,MAINT: Some fixes and minor cleanup based on clang analysis -* `#14484 `__: MAINT: Add `NPY_UNUSED` and `const` qualified suggested by clang +* `#14484 `__: MAINT: Add ``NPY_UNUSED`` and ``const`` qualified suggested by clang * `#14485 `__: MAINT: Silence integer comparison build warnings in assert statements * `#14486 `__: MAINT: distutils: Add newline at the end of printed warnings. * `#14490 `__: BUG: random: Revert gh-14458 and refix gh-14557. @@ -383,7 +389,7 @@ A total of 406 pull requests were merged for this release. * `#14567 `__: DEP: remove deprecated (and private) numpy.testing submodules. * `#14568 `__: BLD, DOC: fix gh-14518, add release note * `#14570 `__: BUG: importing build_src breaks setuptools monkeypatch for msvc14 -* `#14572 `__: DOC: Note runtests.py `-- -s` method to use pytests `-s` +* `#14572 `__: DOC: Note runtests.py ``-- -s`` method to use pytests ``-s`` * `#14573 `__: DOC: update submodule docstrings, remove info.py files * `#14576 `__: DOC: Document the NPY_SCALARKIND values as C variables. * `#14582 `__: MAINT: Bump pytest from 5.1.2 to 5.1.3 @@ -405,30 +411,31 @@ A total of 406 pull requests were merged for this release. * `#14614 `__: MAINT: Bump pytest from 5.1.3 to 5.2.0 * `#14615 `__: MAINT: Add "MAINT" tag to dependabot commit msg * `#14616 `__: DOC: Updated sphinx directive formatting -* `#14620 `__: DEP: Finish deprecation of non-integer `num` in linspace +* `#14620 `__: DEP: Finish deprecation of non-integer ``num`` in linspace * `#14621 `__: DOC: s/OR/AND/ in np.logical_and docstring * `#14623 `__: DOC: misleading np.sinc() documentation * `#14629 `__: DOC: clarify residual in np.polyfit * `#14630 `__: BUILD: change to build_src --verbose-cfg, runtests.py --debug-info * `#14631 `__: BUG: always free clean_sep -* `#14634 `__: DOC: Create `class Extension` docstring and add it to documentation. -* `#14636 `__: DOC: add `printoptions` as a context manager to `set_printoptions` +* `#14634 `__: DOC: Create ``class Extension`` docstring and add it to documentation. +* `#14636 `__: DOC: add ``printoptions`` as a context manager to ``set_printoptions`` * `#14639 `__: DOC: Fix typo in NEP 29 * `#14643 `__: MAINT: Use scalar math power function directly * `#14649 `__: DOC: Add IPython to dependencies needed to build docs. * `#14652 `__: MAINT: Bump pytest-cov from 2.7.1 to 2.8.1 * `#14653 `__: MAINT: Bump pytest from 5.2.0 to 5.2.1 * `#14654 `__: MAINT: Bump pytz from 2019.2 to 2019.3 -* `#14656 `__: MAINT: Use `extract_unit` throughout datetime +* `#14656 `__: MAINT: Use ``extract_unit`` throughout datetime * `#14657 `__: BUG: fix fromfile behavior when reading sub-array dtypes * `#14662 `__: BUG: random: Use correct length when axis is given to shuffle. * `#14669 `__: BUG: Do not rely on undefined behaviour to cast from float to... * `#14674 `__: NEP: add default-dtype-object-deprecation nep 34 * `#14681 `__: MAINT: Remove unused boolean negative/subtract loops -* `#14682 `__: DEP: ufunc `out` argument must be a tuple for multiple outputs -* `#14693 `__: BUG: Fix `np.einsum` errors on Power9 Linux and z/Linux +* `#14682 `__: DEP: ufunc ``out`` argument must be a tuple for multiple outputs +* `#14693 `__: BUG: Fix ``np.einsum`` errors on Power9 Linux and z/Linux * `#14696 `__: DOC: Note release notes process changes on devdocs start page * `#14699 `__: Doc warnings +* `#14703 `__: TST: Adding CI stages, with one initial job to the Travis CI * `#14705 `__: DOC: Switch Markdown link to RST in NEP 29 * `#14709 `__: TST: Divide Azure CI Pipelines into stages. * `#14710 `__: DEP: Finish the out kwarg deprecation for ufunc calls @@ -526,7 +533,7 @@ A total of 406 pull requests were merged for this release. * `#15058 `__: API, DOC: change names to multivariate_hypergeometric, improve docs * `#15059 `__: REL: Prepare for NumPy 1.18.0 release. * `#15109 `__: TST: Check requires_memory immediately before the test -* `#15111 `__: ENH: Add support to sort timedelta64 `NaT` to end of the array +* `#15111 `__: ENH: Add support to sort timedelta64 ``NaT`` to end of the array * `#15112 `__: MAINT: follow-up cleanup for blas64 PR * `#15113 `__: ENH: f2py: add --f2cmap option for specifying the name of .f2py_f2cmap * `#15114 `__: ENH: add support for ILP64 OpenBLAS (without symbol suffix) From 59414b663b2889734b85bebd976dd5ca326c57eb Mon Sep 17 00:00:00 2001 From: Charles Harris Date: Fri, 7 May 2021 09:43:00 -0600 Subject: [PATCH 30/33] DOC: Update 1.17.0-changelog.rst. --- doc/changelog/1.17.0-changelog.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/doc/changelog/1.17.0-changelog.rst b/doc/changelog/1.17.0-changelog.rst index 4177c848fd7e..8179c180bad3 100644 --- a/doc/changelog/1.17.0-changelog.rst +++ b/doc/changelog/1.17.0-changelog.rst @@ -159,7 +159,7 @@ names contributed a patch for the first time. Pull requests merged ==================== -A total of 531 pull requests were merged for this release. +A total of 532 pull requests were merged for this release. * `#4808 `__: ENH: Make the `mode` parameter of np.pad default to 'constant' * `#8131 `__: BUG: Fix help() formatting for deprecated functions. @@ -174,6 +174,7 @@ A total of 531 pull requests were merged for this release. * `#10855 `__: ENH: Adding a count parameter to np.unpackbits * `#11230 `__: MAINT: More cleanup of einsum * `#11233 `__: BUG: ensure i0 does not change the shape. +* `#11358 `__: MAINT: Rewrite numpy.pad without concatenate * `#11684 `__: BUG: Raise when unravel_index, ravel_multi_index are given empty... * `#11689 `__: DOC: Add ref docs for C generic types. * `#11721 `__: BUG: Make `arr.ctypes.data` hold onto a reference to the underlying... From 1863519b772ed44cf8efac20b53f19de63bee305 Mon Sep 17 00:00:00 2001 From: Charles Harris Date: Sat, 8 May 2021 16:53:17 -0600 Subject: [PATCH 31/33] REL, DOC: Prepare for the NumPy 1.20.3 release. * Update 1.20.3-notes.rst * Create 1.20.3-changelog.rst * Fix typo in 1.20.2-notes.rst [skip ci] --- doc/changelog/1.20.3-changelog.rst | 33 ++++++++++++++++++++++++++++ doc/source/release/1.20.2-notes.rst | 3 +-- doc/source/release/1.20.3-notes.rst | 34 ++++++++++++++++++++++++++++- 3 files changed, 67 insertions(+), 3 deletions(-) create mode 100644 doc/changelog/1.20.3-changelog.rst diff --git a/doc/changelog/1.20.3-changelog.rst b/doc/changelog/1.20.3-changelog.rst new file mode 100644 index 000000000000..6e35716ccee6 --- /dev/null +++ b/doc/changelog/1.20.3-changelog.rst @@ -0,0 +1,33 @@ + +Contributors +============ + +A total of 7 people contributed to this release. People with a "+" by their +names contributed a patch for the first time. + +* Anne Archibald +* Bas van Beek +* Charles Harris +* Dong Keun Oh + +* Kamil Choudhury + +* Sayed Adel +* Sebastian Berg + +Pull requests merged +==================== + +A total of 13 pull requests were merged for this release. + +* `#18763 `__: BUG: Correct ``datetime64`` missing type overload for ``datetime.date``... +* `#18764 `__: MAINT: Remove ``__all__`` in favor of explicit re-exports +* `#18768 `__: BLD: Strip extra newline when dumping gfortran version on MacOS +* `#18769 `__: BUG: fix segfault in object/longdouble operations +* `#18794 `__: MAINT: Use towncrier build explicitly +* `#18887 `__: MAINT: Relax certain integer-type constraints +* `#18915 `__: MAINT: Remove unsafe unions and ABCs from return-annotations +* `#18921 `__: MAINT: Allow more recursion depth for scalar tests. +* `#18922 `__: BUG: Initialize the full nditer buffer in case of error +* `#18923 `__: BLD: remove unnecessary flag ``-faltivec`` on macOS +* `#18924 `__: MAINT, CI: treats _SIMD module build warnings as errors through... +* `#18925 `__: BUG: for MINGW, threads.h existence test requires GLIBC > 2.12 +* `#18941 `__: BUG: Make changelog recognize gh- as a PR number prefix. diff --git a/doc/source/release/1.20.2-notes.rst b/doc/source/release/1.20.2-notes.rst index cdf45b65ea26..10d39f7f6389 100644 --- a/doc/source/release/1.20.2-notes.rst +++ b/doc/source/release/1.20.2-notes.rst @@ -4,10 +4,9 @@ NumPy 1.20.2 Release Notes ========================== -NumPy 1,20.2 is a bugfix release containing several fixes merged to the main +NumPy 1.20.2 is a bugfix release containing several fixes merged to the main branch after the NumPy 1.20.1 release. - Contributors ============ diff --git a/doc/source/release/1.20.3-notes.rst b/doc/source/release/1.20.3-notes.rst index 5b3c200b684b..99001de373a2 100644 --- a/doc/source/release/1.20.3-notes.rst +++ b/doc/source/release/1.20.3-notes.rst @@ -4,6 +4,38 @@ NumPy 1.20.3 Release Notes ========================== -NumPy 1,20.3 is a bugfix release containing several fixes merged to the main +NumPy 1.20.3 is a bugfix release containing several fixes merged to the main branch after the NumPy 1.20.2 release. +Contributors +============ + +A total of 7 people contributed to this release. People with a "+" by their +names contributed a patch for the first time. + +* Anne Archibald +* Bas van Beek +* Charles Harris +* Dong Keun Oh + +* Kamil Choudhury + +* Sayed Adel +* Sebastian Berg + +Pull requests merged +==================== + +A total of 13 pull requests were merged for this release. + +* `#18763 `__: BUG: Correct ``datetime64`` missing type overload for ``datetime.date``... +* `#18764 `__: MAINT: Remove ``__all__`` in favor of explicit re-exports +* `#18768 `__: BLD: Strip extra newline when dumping gfortran version on MacOS +* `#18769 `__: BUG: fix segfault in object/longdouble operations +* `#18794 `__: MAINT: Use towncrier build explicitly +* `#18887 `__: MAINT: Relax certain integer-type constraints +* `#18915 `__: MAINT: Remove unsafe unions and ABCs from return-annotations +* `#18921 `__: MAINT: Allow more recursion depth for scalar tests. +* `#18922 `__: BUG: Initialize the full nditer buffer in case of error +* `#18923 `__: BLD: remove unnecessary flag ``-faltivec`` on macOS +* `#18924 `__: MAINT, CI: treats _SIMD module build warnings as errors through... +* `#18925 `__: BUG: for MINGW, threads.h existence test requires GLIBC > 2.12 +* `#18941 `__: BUG: Make changelog recognize gh- as a PR number prefix. From 863982159be605d719584e9551a0d6d575823406 Mon Sep 17 00:00:00 2001 From: Charles Harris Date: Sun, 9 May 2021 08:45:23 -0600 Subject: [PATCH 32/33] BUG: Fix failing mypy test in 1.20.x. --- numpy/typing/tests/data/fail/array_constructors.py | 4 ++-- test_requirements.txt | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/numpy/typing/tests/data/fail/array_constructors.py b/numpy/typing/tests/data/fail/array_constructors.py index 9cb59fe5f72e..f13fdacb26c9 100644 --- a/numpy/typing/tests/data/fail/array_constructors.py +++ b/numpy/typing/tests/data/fail/array_constructors.py @@ -7,10 +7,10 @@ np.require(a, requirements="TEST") # E: incompatible type np.zeros("test") # E: incompatible type -np.zeros() # E: Too few arguments +np.zeros() # E: Missing positional argument np.ones("test") # E: incompatible type -np.ones() # E: Too few arguments +np.ones() # E: Missing positional argument np.array(0, float, True) # E: Too many positional diff --git a/test_requirements.txt b/test_requirements.txt index d6c31774a266..4dbda925b37b 100644 --- a/test_requirements.txt +++ b/test_requirements.txt @@ -10,6 +10,6 @@ pickle5; python_version == '3.7' and platform_python_implementation != 'PyPy' cffi # For testing types. Notes on the restrictions: # - Mypy relies on C API features not present in PyPy -# - Mypy doesn't currently work on Python 3.9 -mypy==0.790; platform_python_implementation != "PyPy" -typing_extensions +# - There is no point in installing typing_extensions without mypy +mypy==0.812; platform_python_implementation != "PyPy" +typing_extensions==3.10.0.0; platform_python_implementation != "PyPy" From 27b98cbe0dd9d2969e9c227e7a2070aa56f41d6d Mon Sep 17 00:00:00 2001 From: Charles Harris Date: Sat, 8 May 2021 17:49:33 -0600 Subject: [PATCH 33/33] REL: NumPy 1.20.3 release. --- doc/changelog/1.20.3-changelog.rst | 4 +++- doc/source/release/1.20.3-notes.rst | 4 +++- setup.py | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/doc/changelog/1.20.3-changelog.rst b/doc/changelog/1.20.3-changelog.rst index 6e35716ccee6..df7f1056521a 100644 --- a/doc/changelog/1.20.3-changelog.rst +++ b/doc/changelog/1.20.3-changelog.rst @@ -16,7 +16,7 @@ names contributed a patch for the first time. Pull requests merged ==================== -A total of 13 pull requests were merged for this release. +A total of 15 pull requests were merged for this release. * `#18763 `__: BUG: Correct ``datetime64`` missing type overload for ``datetime.date``... * `#18764 `__: MAINT: Remove ``__all__`` in favor of explicit re-exports @@ -31,3 +31,5 @@ A total of 13 pull requests were merged for this release. * `#18924 `__: MAINT, CI: treats _SIMD module build warnings as errors through... * `#18925 `__: BUG: for MINGW, threads.h existence test requires GLIBC > 2.12 * `#18941 `__: BUG: Make changelog recognize gh- as a PR number prefix. +* `#18948 `__: REL, DOC: Prepare for the NumPy 1.20.3 release. +* `#18953 `__: BUG: Fix failing mypy test in 1.20.x. diff --git a/doc/source/release/1.20.3-notes.rst b/doc/source/release/1.20.3-notes.rst index 99001de373a2..8c25b3cc3215 100644 --- a/doc/source/release/1.20.3-notes.rst +++ b/doc/source/release/1.20.3-notes.rst @@ -24,7 +24,7 @@ names contributed a patch for the first time. Pull requests merged ==================== -A total of 13 pull requests were merged for this release. +A total of 15 pull requests were merged for this release. * `#18763 `__: BUG: Correct ``datetime64`` missing type overload for ``datetime.date``... * `#18764 `__: MAINT: Remove ``__all__`` in favor of explicit re-exports @@ -39,3 +39,5 @@ A total of 13 pull requests were merged for this release. * `#18924 `__: MAINT, CI: treats _SIMD module build warnings as errors through... * `#18925 `__: BUG: for MINGW, threads.h existence test requires GLIBC > 2.12 * `#18941 `__: BUG: Make changelog recognize gh- as a PR number prefix. +* `#18948 `__: REL, DOC: Prepare for the NumPy 1.20.3 release. +* `#18953 `__: BUG: Fix failing mypy test in 1.20.x. diff --git a/setup.py b/setup.py index 65cbd87197f9..0a925eb3b4fd 100755 --- a/setup.py +++ b/setup.py @@ -57,7 +57,7 @@ MAJOR = 1 MINOR = 20 MICRO = 3 -ISRELEASED = False +ISRELEASED = True VERSION = '%d.%d.%d' % (MAJOR, MINOR, MICRO) # The first version not in the `Programming Language :: Python :: ...` classifiers above