Imported Upstream version 1.21.2 upstream/1.21.2
authorDongHun Kwak <dh0128.kwak@samsung.com>
Fri, 15 Jul 2022 02:14:49 +0000 (11:14 +0900)
committerDongHun Kwak <dh0128.kwak@samsung.com>
Fri, 15 Jul 2022 02:14:49 +0000 (11:14 +0900)
32 files changed:
.coveragerc [new file with mode: 0644]
MANIFEST.in
PKG-INFO
_configtest.o
doc/changelog/1.21.2-changelog.rst [new file with mode: 0644]
doc/source/release.rst
doc/source/release/1.21.2-notes.rst [new file with mode: 0644]
numpy/__init__.pyi
numpy/_version.py
numpy/core/code_generators/generate_umath.py
numpy/core/include/numpy/npy_cpu.h
numpy/core/src/multiarray/lowlevel_strided_loops.c.src
numpy/core/src/umath/ufunc_object.c
numpy/core/tests/test_deprecations.py
numpy/core/tests/test_nditer.py
numpy/core/tests/test_scalarprint.py
numpy/core/tests/test_ufunc.py
numpy/core/tests/test_umath_complex.py
numpy/distutils/ccompiler_opt.py
numpy/distutils/system_info.py
numpy/lib/tests/test_utils.py
numpy/random/src/philox/philox.h
numpy/typing/_array_like.py
numpy/typing/_dtype_like.py
numpy/typing/tests/data/reveal/nditer.py [new file with mode: 0644]
numpy/typing/tests/test_typing_extensions.py [new file with mode: 0644]
pavement.py
pyproject.toml
runtests.py
setup.py
test_requirements.txt
tools/cythonize.py

diff --git a/.coveragerc b/.coveragerc
new file mode 100644 (file)
index 0000000..9048b9c
--- /dev/null
@@ -0,0 +1,4 @@
+[run]
+branch = True
+include = */numpy/*
+disable_warnings = include-ignored
index 8ec62123b99875c8ee24b561ad2d239f2bec2f3d..ab6ecd518e1bc568d2710d4088a2cac7c0201897 100644 (file)
@@ -12,6 +12,9 @@ exclude LICENSES_bundled.txt
 exclude .*
 exclude azure-*.yml
 
+# Include coveragerc for runtests.py
+include .coveragerc
+
 # Sub-directories. Included are: numpy/, doc/, benchmarks/, tools/
 include numpy/_version.py
 recursive-include numpy/random *.pyx *.pxd *.pyx.in *.pxd.in
index 8977ea8035d1117d9252a9b7f99f199315e60f3d..26d4e367db792883f476a501feb4351b21709bfa 100644 (file)
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,6 +1,6 @@
 Metadata-Version: 1.2
 Name: numpy
-Version: 1.21.1
+Version: 1.21.2
 Summary:  NumPy is the fundamental package for array computing with Python.
 Home-page: https://www.numpy.org
 Author: Travis E. Oliphant et al.
@@ -42,6 +42,7 @@ Classifier: Programming Language :: Python :: 3
 Classifier: Programming Language :: Python :: 3.7
 Classifier: Programming Language :: Python :: 3.8
 Classifier: Programming Language :: Python :: 3.9
+Classifier: Programming Language :: Python :: 3.10
 Classifier: Programming Language :: Python :: 3 :: Only
 Classifier: Programming Language :: Python :: Implementation :: CPython
 Classifier: Topic :: Software Development
@@ -51,4 +52,4 @@ Classifier: Operating System :: Microsoft :: Windows
 Classifier: Operating System :: POSIX
 Classifier: Operating System :: Unix
 Classifier: Operating System :: MacOS
-Requires-Python: >=3.7
+Requires-Python: >=3.7,<3.11
index 8fdec4ddf62d02a266a062df9a48559e4ae330ee..4d632006d5e4754b83b4d9e4e54f312b60d829a5 100644 (file)
Binary files a/_configtest.o and b/_configtest.o differ
diff --git a/doc/changelog/1.21.2-changelog.rst b/doc/changelog/1.21.2-changelog.rst
new file mode 100644 (file)
index 0000000..f23fb0c
--- /dev/null
@@ -0,0 +1,41 @@
+
+Contributors
+============
+
+A total of 10 people contributed to this release.  People with a "+" by their
+names contributed a patch for the first time.
+
+* Bas van Beek
+* Carl Johnsen +
+* Charles Harris
+* Gwyn Ciesla +
+* Matthieu Dartiailh
+* Matti Picus
+* Niyas Sait +
+* Ralf Gommers
+* Sayed Adel
+* Sebastian Berg
+
+Pull requests merged
+====================
+
+A total of 18 pull requests were merged for this release.
+
+* `#19497 <https://github.com/numpy/numpy/pull/19497>`__: MAINT: set Python version for 1.21.x to ``<3.11``
+* `#19533 <https://github.com/numpy/numpy/pull/19533>`__: BUG: Fix an issue wherein importing ``numpy.typing`` could raise
+* `#19646 <https://github.com/numpy/numpy/pull/19646>`__: MAINT: Update Cython version for Python 3.10.
+* `#19648 <https://github.com/numpy/numpy/pull/19648>`__: TST: Bump the python 3.10 test version from beta4 to rc1
+* `#19651 <https://github.com/numpy/numpy/pull/19651>`__: TST: avoid distutils.sysconfig in runtests.py
+* `#19652 <https://github.com/numpy/numpy/pull/19652>`__: MAINT: add missing dunder method to nditer type hints
+* `#19656 <https://github.com/numpy/numpy/pull/19656>`__: BLD, SIMD: Fix testing extra checks when ``-Werror`` isn't applicable...
+* `#19657 <https://github.com/numpy/numpy/pull/19657>`__: BUG: Remove logical object ufuncs with bool output
+* `#19658 <https://github.com/numpy/numpy/pull/19658>`__: MAINT: Include .coveragerc in source distributions to support...
+* `#19659 <https://github.com/numpy/numpy/pull/19659>`__: BUG: Fix bad write in masked iterator output copy paths
+* `#19660 <https://github.com/numpy/numpy/pull/19660>`__: ENH: Add support for windows on arm targets
+* `#19661 <https://github.com/numpy/numpy/pull/19661>`__: BUG: add base to templated arguments for platlib
+* `#19662 <https://github.com/numpy/numpy/pull/19662>`__: BUG,DEP: Non-default UFunc signature/dtype usage should be deprecated
+* `#19666 <https://github.com/numpy/numpy/pull/19666>`__: MAINT: Add Python 3.10 to supported versions.
+* `#19668 <https://github.com/numpy/numpy/pull/19668>`__: TST,BUG: Sanitize path-separators when running ``runtest.py``
+* `#19671 <https://github.com/numpy/numpy/pull/19671>`__: BLD: load extra flags when checking for libflame
+* `#19676 <https://github.com/numpy/numpy/pull/19676>`__: BLD: update circleCI docker image
+* `#19677 <https://github.com/numpy/numpy/pull/19677>`__: REL: Prepare for 1.21.2 release.
index 4a9d2b1945faff90f4fec6f70882dc52dce21d2b..99856e990d96458302b0821ad6c5f3a8d95c3b69 100644 (file)
@@ -5,6 +5,7 @@ Release Notes
 .. toctree::
     :maxdepth: 3
 
+    1.21.2 <release/1.21.2-notes>
     1.21.1 <release/1.21.1-notes>
     1.21.0 <release/1.21.0-notes>
     1.20.3 <release/1.20.3-notes>
diff --git a/doc/source/release/1.21.2-notes.rst b/doc/source/release/1.21.2-notes.rst
new file mode 100644 (file)
index 0000000..ee2c525
--- /dev/null
@@ -0,0 +1,59 @@
+.. currentmodule:: numpy
+
+==========================
+NumPy 1.21.2 Release Notes
+==========================
+
+The NumPy 1.21.2 is maintenance release that fixes bugs discovered after
+1.21.1. It also provides 64 bit manylinux Python 3.10.0rc1 wheels for
+downstream testing. Note that Python 3.10 is not yet final. There is also
+preliminary support for Windows on ARM64 builds, but there is no OpenBLAS for
+that platform and no wheels are available.
+
+The Python versions supported for this release are 3.7-3.9. The 1.21.x series
+is compatible with Python 3.10.0rc1 and Python 3.10 will be officially
+supported after it is released. The previous problems with gcc-11.1 have been
+fixed by gcc-11.2, check your version if you are using gcc-11.
+
+
+Contributors
+============
+
+A total of 10 people contributed to this release.  People with a "+" by their
+names contributed a patch for the first time.
+
+* Bas van Beek
+* Carl Johnsen +
+* Charles Harris
+* Gwyn Ciesla +
+* Matthieu Dartiailh
+* Matti Picus
+* Niyas Sait +
+* Ralf Gommers
+* Sayed Adel
+* Sebastian Berg
+
+
+Pull requests merged
+====================
+
+A total of 18 pull requests were merged for this release.
+
+* `#19497 <https://github.com/numpy/numpy/pull/19497>`__: MAINT: set Python version for 1.21.x to ``<3.11``
+* `#19533 <https://github.com/numpy/numpy/pull/19533>`__: BUG: Fix an issue wherein importing ``numpy.typing`` could raise
+* `#19646 <https://github.com/numpy/numpy/pull/19646>`__: MAINT: Update Cython version for Python 3.10.
+* `#19648 <https://github.com/numpy/numpy/pull/19648>`__: TST: Bump the python 3.10 test version from beta4 to rc1
+* `#19651 <https://github.com/numpy/numpy/pull/19651>`__: TST: avoid distutils.sysconfig in runtests.py
+* `#19652 <https://github.com/numpy/numpy/pull/19652>`__: MAINT: add missing dunder method to nditer type hints
+* `#19656 <https://github.com/numpy/numpy/pull/19656>`__: BLD, SIMD: Fix testing extra checks when ``-Werror`` isn't applicable...
+* `#19657 <https://github.com/numpy/numpy/pull/19657>`__: BUG: Remove logical object ufuncs with bool output
+* `#19658 <https://github.com/numpy/numpy/pull/19658>`__: MAINT: Include .coveragerc in source distributions to support...
+* `#19659 <https://github.com/numpy/numpy/pull/19659>`__: BUG: Fix bad write in masked iterator output copy paths
+* `#19660 <https://github.com/numpy/numpy/pull/19660>`__: ENH: Add support for windows on arm targets
+* `#19661 <https://github.com/numpy/numpy/pull/19661>`__: BUG: add base to templated arguments for platlib
+* `#19662 <https://github.com/numpy/numpy/pull/19662>`__: BUG,DEP: Non-default UFunc signature/dtype usage should be deprecated
+* `#19666 <https://github.com/numpy/numpy/pull/19666>`__: MAINT: Add Python 3.10 to supported versions.
+* `#19668 <https://github.com/numpy/numpy/pull/19668>`__: TST,BUG: Sanitize path-separators when running ``runtest.py``
+* `#19671 <https://github.com/numpy/numpy/pull/19671>`__: BLD: load extra flags when checking for libflame
+* `#19676 <https://github.com/numpy/numpy/pull/19676>`__: BLD: update circleCI docker image
+* `#19677 <https://github.com/numpy/numpy/pull/19677>`__: REL: Prepare for 1.21.2 release.
index 74c33b16243e00b9b6dc6d9d14492be867de1d84..d07e32f1c27628d0c68b0fac8070442d1b38ce98 100644 (file)
@@ -169,6 +169,7 @@ from typing import (
     Generic,
     IO,
     Iterable,
+    Iterator,
     List,
     Mapping,
     NoReturn,
@@ -729,6 +730,21 @@ class nditer:
         buffersize: Any = ...,
     ) -> Any: ...
     def __getattr__(self, key: str) -> Any: ...
+    def __enter__(self) -> nditer: ...
+    def __exit__(
+        self,
+        exc_type: None | Type[BaseException],
+        exc_value: None | BaseException,
+        traceback: None | TracebackType,
+    ) -> None: ...
+    def __iter__(self) -> Iterator[Any]: ...
+    def __next__(self) -> Any: ...
+    def __len__(self) -> int: ...
+    def __copy__(self) -> nditer: ...
+    def __getitem__(self, index: SupportsIndex | slice) -> Any: ...
+    def __setitem__(self, index: SupportsIndex | slice, value: Any) -> None: ...
+    def __delitem__(self, key: SupportsIndex | slice) -> None: ...
+
 
 class poly1d:
     def __init__(
index 0a5a25f2c15857af60e25b6dd5b4a03be6ccb438..582f1962caf7909c95273c3d85cec89e4a3ccee8 100644 (file)
@@ -8,11 +8,11 @@ import json
 
 version_json = '''
 {
- "date": "2021-07-18T11:34:41-0600",
+ "date": "2021-08-15T12:15:47-0600",
  "dirty": false,
  "error": null,
- "full-revisionid": "df6d2600c51502e1877aac563658d0616a75c5e5",
- "version": "1.21.1"
+ "full-revisionid": "2fe48d2d98a85c8ea3f3d5caffd952ea69e99335",
+ "version": "1.21.2"
 }
 '''  # END VERSION_JSON
 
index 9e94f9cccc47397425a3e673c7646609e8fa2331..d567b2eb9aaf2a120dbd7070910afe2f2545fe67 100644 (file)
@@ -489,7 +489,6 @@ defdict = {
           'PyUFunc_SimpleBinaryComparisonTypeResolver',
           TD(nodatetime_or_obj, out='?', simd=[('avx2', ints)]),
           TD(O, f='npy_ObjectLogicalAnd'),
-          TD(O, f='npy_ObjectLogicalAnd', out='?'),
           ),
 'logical_not':
     Ufunc(1, 1, None,
@@ -497,7 +496,6 @@ defdict = {
           None,
           TD(nodatetime_or_obj, out='?', simd=[('avx2', ints)]),
           TD(O, f='npy_ObjectLogicalNot'),
-          TD(O, f='npy_ObjectLogicalNot', out='?'),
           ),
 'logical_or':
     Ufunc(2, 1, False_,
@@ -505,13 +503,13 @@ defdict = {
           'PyUFunc_SimpleBinaryComparisonTypeResolver',
           TD(nodatetime_or_obj, out='?', simd=[('avx2', ints)]),
           TD(O, f='npy_ObjectLogicalOr'),
-          TD(O, f='npy_ObjectLogicalOr', out='?'),
           ),
 'logical_xor':
     Ufunc(2, 1, False_,
           docstrings.get('numpy.core.umath.logical_xor'),
           'PyUFunc_SimpleBinaryComparisonTypeResolver',
           TD(nodatetime_or_obj, out='?'),
+          # TODO: using obj.logical_xor() seems pretty much useless:
           TD(P, f='logical_xor'),
           ),
 'maximum':
index 065176ac5fb65164c6945c9bc0a79fece3b0c5ef..bc1fad72f7681ddc5a6d65ee724bed25f05c6053 100644 (file)
@@ -63,7 +63,8 @@
     #define NPY_CPU_HPPA
 #elif defined(__alpha__)
     #define NPY_CPU_ALPHA
-#elif defined(__arm__) || defined(__aarch64__)
+#elif defined(__arm__) || defined(__aarch64__) || defined(_M_ARM64)
+    /* _M_ARM64 is defined in MSVC for ARM64 compilation on Windows */
     #if defined(__ARMEB__) || defined(__AARCH64EB__)
         #if defined(__ARM_32BIT_STATE)
             #define NPY_CPU_ARMEB_AARCH32
         #else
             #define NPY_CPU_ARMEB
         #endif
-    #elif defined(__ARMEL__) || defined(__AARCH64EL__)
+    #elif defined(__ARMEL__) || defined(__AARCH64EL__) || defined(_M_ARM64)
         #if defined(__ARM_32BIT_STATE)
             #define NPY_CPU_ARMEL_AARCH32
-        #elif defined(__ARM_64BIT_STATE)
+        #elif defined(__ARM_64BIT_STATE) || defined(_M_ARM64)
             #define NPY_CPU_ARMEL_AARCH64
         #else
             #define NPY_CPU_ARMEL
index 631042dae1d76d9929a5a758d7ed7ec759f7a4d0..e533e4932f3ed119b16e5b6d806cec835370df56 100644 (file)
@@ -1316,7 +1316,7 @@ PyArray_TransferMaskedStridedToNDim(npy_intp ndim,
                 args, &count, strides, mask, mask_stride, cast_info->auxdata);
     }
     int res = stransfer(&cast_info->context,
-            args, &count, strides, mask, mask_stride, cast_info->auxdata);
+            args, &N, strides, mask, mask_stride, cast_info->auxdata);
     if (res < 0) {
         return -1;
     }
index 9e73dfd94a9c1f2179d4e8ec7c90d63c91bf910f..068ff2d7eeaccbbaa1606d24c6976303408a9fad 100644 (file)
@@ -4436,7 +4436,8 @@ _get_dtype(PyObject *dtype_obj) {
         else if (NPY_UNLIKELY(out->singleton != descr)) {
             /* This does not warn about `metadata`, but units is important. */
             if (!PyArray_EquivTypes(out->singleton, descr)) {
-                PyErr_Format(PyExc_TypeError,
+                /* Deprecated NumPy 1.21.2 (was an accidental error in 1.21) */
+                if (DEPRECATE(
                         "The `dtype` and `signature` arguments to "
                         "ufuncs only select the general DType and not details "
                         "such as the byte order or time unit (with rare "
@@ -4446,9 +4447,11 @@ _get_dtype(PyObject *dtype_obj) {
                         "In rare cases where the time unit was preserved, "
                         "either cast the inputs or provide an output array. "
                         "In the future NumPy may transition to allow providing "
-                        "`dtype=` to denote the outputs `dtype` as well");
-                Py_DECREF(descr);
-                return NULL;
+                        "`dtype=` to denote the outputs `dtype` as well. "
+                        "(Deprecated NumPy 1.21)") < 0) {
+                    Py_DECREF(descr);
+                    return NULL;
+                }
             }
         }
         Py_INCREF(out);
index 42e632e4aa2a7973b54f09ce2a0dae1213a4888f..29603e3cc79cc00be161c04cd0e7c4f551c6302e 100644 (file)
@@ -1174,3 +1174,36 @@ class TestCtypesGetter(_DeprecationTestCase):
     )
     def test_not_deprecated(self, name: str) -> None:
         self.assert_not_deprecated(lambda: getattr(self.ctypes, name))
+
+
+class TestUFuncForcedDTypeWarning(_DeprecationTestCase):
+    message = "The `dtype` and `signature` arguments to ufuncs only select the"
+
+    def test_not_deprecated(self):
+        import pickle
+        # does not warn (test relies on bad pickling behaviour, simply remove
+        # it if the `assert int64 is not int64_2` should start failing.
+        int64 = np.dtype("int64")
+        int64_2 = pickle.loads(pickle.dumps(int64))
+        assert int64 is not int64_2
+        self.assert_not_deprecated(lambda: np.add(3, 4, dtype=int64_2))
+
+    def test_deprecation(self):
+        int64 = np.dtype("int64")
+        self.assert_deprecated(lambda: np.add(3, 5, dtype=int64.newbyteorder()))
+        self.assert_deprecated(lambda: np.add(3, 5, dtype="m8[ns]"))
+
+    def test_behaviour(self):
+        int64 = np.dtype("int64")
+        arr = np.arange(10, dtype="m8[s]")
+
+        with pytest.warns(DeprecationWarning, match=self.message):
+            np.add(3, 5, dtype=int64.newbyteorder())
+        with pytest.warns(DeprecationWarning, match=self.message):
+            np.add(3, 5, dtype="m8[ns]")  # previously used the "ns"
+        with pytest.warns(DeprecationWarning, match=self.message):
+            np.add(arr, arr, dtype="m8[ns]")  # never preserved the "ns"
+        with pytest.warns(DeprecationWarning, match=self.message):
+            np.maximum(arr, arr, dtype="m8[ns]")  # previously used the "ns"
+        with pytest.warns(DeprecationWarning, match=self.message):
+            np.maximum.reduce(arr, dtype="m8[ns]")  # never preserved the "ns"
index adcf921f60163236c966f9df3495da860703743f..6b743ab27301e7c7fe68f16f5a3d213cc483c5bc 100644 (file)
@@ -2738,7 +2738,12 @@ def _is_buffered(iterator):
 @pytest.mark.parametrize("a",
         [np.zeros((3,), dtype='f8'),
          np.zeros((9876, 3*5), dtype='f8')[::2, :],
-         np.zeros((4, 312, 124, 3), dtype='f8')[::2, :, ::2, :]])
+         np.zeros((4, 312, 124, 3), dtype='f8')[::2, :, ::2, :],
+         # Also test with the last dimension strided (so it does not fit if
+         # there is repeated access)
+         np.zeros((9,), dtype='f8')[::3],
+         np.zeros((9876, 3*10), dtype='f8')[::2, ::5],
+         np.zeros((4, 312, 124, 3), dtype='f8')[::2, :, ::2, ::-1]])
 def test_iter_writemasked(a):
     # Note, the slicing above is to ensure that nditer cannot combine multiple
     # axes into one.  The repetition is just to make things a bit more
index 62047268339107c20b0b997b7da1601ea19c4ad4..2f1c3bc5e3095c95b24dc473ee4b9aafb2b7d54e 100644 (file)
@@ -154,7 +154,8 @@ class TestRealScalars:
                     "0.00000000000000000000000000000000000000000000140129846432"
                     "4817070923729583289916131280261941876515771757068283889791"
                     "08268586060148663818836212158203125")
-        assert_equal(fpos64(0.5**(1022 + 52), unique=False, precision=1074),
+        
+        assert_equal(fpos64(5e-324, unique=False, precision=1074),
                     "0.00000000000000000000000000000000000000000000000000000000"
                     "0000000000000000000000000000000000000000000000000000000000"
                     "0000000000000000000000000000000000000000000000000000000000"
index a47f1df49871b5e917a692bdb0d927c2b23998db..091b47619a4639c02befef5838c1551041c78008 100644 (file)
@@ -517,27 +517,6 @@ class TestUfunc:
         np.add(arr, arr, dtype="m")
         np.maximum(arr, arr, dtype="m")
 
-    def test_forced_dtype_warning(self):
-        # does not warn (test relies on bad pickling behaviour, simply remove
-        # it if the `assert int64 is not int64_2` should start failing.
-        int64 = np.dtype("int64")
-        int64_2 = pickle.loads(pickle.dumps(int64))
-        assert int64 is not int64_2
-        np.add(3, 4, dtype=int64_2)
-
-        arr = np.arange(10, dtype="m8[s]")
-        msg = "The `dtype` and `signature` arguments to ufuncs only select the"
-        with pytest.raises(TypeError, match=msg):
-            np.add(3, 5, dtype=int64.newbyteorder())
-        with pytest.raises(TypeError, match=msg):
-            np.add(3, 5, dtype="m8[ns]")  # previously used the "ns"
-        with pytest.raises(TypeError, match=msg):
-            np.add(arr, arr, dtype="m8[ns]")  # never preserved the "ns"
-        with pytest.raises(TypeError, match=msg):
-            np.maximum(arr, arr, dtype="m8[ns]")  # previously used the "ns"
-        with pytest.raises(TypeError, match=msg):
-            np.maximum.reduce(arr, dtype="m8[ns]")  # never preserved the "ns"
-
     def test_true_divide(self):
         a = np.array(10)
         b = np.array(20)
@@ -2029,6 +2008,27 @@ class TestUfunc:
             assert_raises(TypeError, f, a, b)
             assert_raises(TypeError, f, c, a)
 
+    @pytest.mark.parametrize("ufunc",
+             [np.logical_and, np.logical_or])  # logical_xor object loop is bad
+    @pytest.mark.parametrize("signature",
+             [(None, None, object), (object, None, None),
+              (None, object, None)])
+    def test_logical_ufuncs_object_signatures(self, ufunc, signature):
+        a = np.array([True, None, False], dtype=object)
+        res = ufunc(a, a, signature=signature)
+        assert res.dtype == object
+
+    @pytest.mark.parametrize("ufunc",
+            [np.logical_and, np.logical_or, np.logical_xor])
+    @pytest.mark.parametrize("signature",
+                 [(bool, None, object), (object, None, bool),
+                  (None, object, bool)])
+    def test_logical_ufuncs_mixed_object_signatures(self, ufunc, signature):
+        # Most mixed signatures fail (except those with bool out, e.g. `OO->?`)
+        a = np.array([True, None, False])
+        with pytest.raises(TypeError):
+            ufunc(a, a, signature=signature)
+
     def test_reduce_noncontig_output(self):
         # Check that reduction deals with non-contiguous output arrays
         # appropriately.
index c051cd61b6606a912838ac1ec08421d3761d12e9..ad09830d4c656b99e876f416a3305ed682a4c365 100644 (file)
@@ -372,11 +372,18 @@ class TestCpow:
         x = np.array([1, 1j,         2,  2.5+.37j, np.inf, np.nan])
         y = np.array([1, 1j, -0.5+1.5j, -0.5+1.5j,      2,      3])
         lx = list(range(len(x)))
-        # Compute the values for complex type in python
-        p_r = [complex(x[i]) ** complex(y[i]) for i in lx]
-        # Substitute a result allowed by C99 standard
-        p_r[4] = complex(np.inf, np.nan)
-        # Do the same with numpy complex scalars
+
+        # Hardcode the expected `builtins.complex` values,
+        # as complex exponentiation is broken as of bpo-44698
+        p_r = [
+            1+0j,
+            0.20787957635076193+0j,
+            0.35812203996480685+0.6097119028618724j,
+            0.12659112128185032+0.48847676699581527j,
+            complex(np.inf, np.nan),
+            complex(np.nan, np.nan),
+        ]
+
         n_r = [x[i] ** y[i] for i in lx]
         for i in lx:
             assert_almost_equal(n_r[i], p_r[i], err_msg='Loop %d\n' % i)
@@ -385,11 +392,18 @@ class TestCpow:
         x = np.array([1, 1j,         2,  2.5+.37j, np.inf, np.nan])
         y = np.array([1, 1j, -0.5+1.5j, -0.5+1.5j,      2,      3])
         lx = list(range(len(x)))
-        # Compute the values for complex type in python
-        p_r = [complex(x[i]) ** complex(y[i]) for i in lx]
-        # Substitute a result allowed by C99 standard
-        p_r[4] = complex(np.inf, np.nan)
-        # Do the same with numpy arrays
+
+        # Hardcode the expected `builtins.complex` values,
+        # as complex exponentiation is broken as of bpo-44698
+        p_r = [
+            1+0j,
+            0.20787957635076193+0j,
+            0.35812203996480685+0.6097119028618724j,
+            0.12659112128185032+0.48847676699581527j,
+            complex(np.inf, np.nan),
+            complex(np.nan, np.nan),
+        ]
+
         n_r = x ** y
         for i in lx:
             assert_almost_equal(n_r[i], p_r[i], err_msg='Loop %d\n' % i)
@@ -583,7 +597,7 @@ class TestComplexAbsoluteMixedDTypes:
     @pytest.mark.parametrize("stride", [-4,-3,-2,-1,1,2,3,4])
     @pytest.mark.parametrize("astype", [np.complex64, np.complex128])
     @pytest.mark.parametrize("func", ['abs', 'square', 'conjugate'])
-    
+
     def test_array(self, stride, astype, func):
         dtype = [('template_id', '<i8'), ('bank_chisq','<f4'),
                  ('bank_chisq_dof','<i8'), ('chisq', '<f4'), ('chisq_dof','<i8'),
@@ -602,9 +616,9 @@ class TestComplexAbsoluteMixedDTypes:
         myfunc = getattr(np, func)
         a = vec['mycomplex']
         g = myfunc(a[::stride])
-        
+
         b = vec['mycomplex'].copy()
         h = myfunc(b[::stride])
-        
+
         assert_array_max_ulp(h.real, g.real, 1)
         assert_array_max_ulp(h.imag, g.imag, 1)
index 47d07ad4ab22d1df856539420b175852e872657b..1942aa06ee27190402c42b0149a6ef6871c6651d 100644 (file)
@@ -193,7 +193,12 @@ class _Config:
         clang = dict(
             native = '-march=native',
             opt = "-O3",
-            werror = '-Werror'
+            # One of the following flags needs to be applicable for Clang to
+            # guarantee the sanity of the testing process, however in certain
+            # cases `-Werror` gets skipped during the availability test due to
+            # "unused arguments" warnings.
+            # see https://github.com/numpy/numpy/issues/19624
+            werror = '-Werror-implicit-function-declaration -Werror'
         ),
         icc = dict(
             native = '-xHost',
index 82e864a5c3e2ca79d284a649b3fdb3e223a82016..59de69d77f8bd4bd0b22da4b875d30a721477f47 100644 (file)
@@ -2426,6 +2426,10 @@ class flame_info(system_info):
         if info is None:
             return
 
+        # Add the extra flag args to info
+        extra_info = self.calc_extra_info()
+        dict_append(info, **extra_info)
+
         if self.check_embedded_lapack(info):
             # check if the user has supplied all information required
             self.set_info(**info)
index 8a877ae698541c33c78e29b67d390f3703c117f3..72c91836ff2b4493dc7c98bcfacc6cbc75e7e293 100644 (file)
@@ -11,6 +11,10 @@ from io import StringIO
 
 
 @pytest.mark.skipif(sys.flags.optimize == 2, reason="Python running -OO")
+@pytest.mark.skipif(
+    sys.version_info == (3, 10, 0, "candidate", 1),
+    reason="Broken as of bpo-44524",
+)
 def test_lookfor():
     out = StringIO()
     utils.lookfor('eigenvalue', module='numpy', output=out,
@@ -160,7 +164,7 @@ def test_info_method_heading():
     class WithPublicMethods:
         def first_method():
             pass
-            
+
     def _has_method_heading(cls):
         out = StringIO()
         utils.info(cls, output=out)
index c72424a975efee1ffe80d204f9e78ed53c605a3d..8844acc157256afef86edb3b78a3d4f36d339b4b 100644 (file)
@@ -33,10 +33,16 @@ static NPY_INLINE uint64_t mulhilo64(uint64_t a, uint64_t b, uint64_t *hip) {
   return (uint64_t)product;
 }
 #else
-#ifdef _WIN32
+#if defined(_WIN32)
 #include <intrin.h>
 #if defined(_WIN64) && defined(_M_AMD64)
 #pragma intrinsic(_umul128)
+#elif defined(_WIN64) && defined(_M_ARM64)
+#pragma intrinsic(__umulh)
+static NPY_INLINE uint64_t _umul128(uint64_t a, uint64_t b, uint64_t *high) {
+  *high = __umulh(a, b);
+  return a * b;
+}
 #else
 #pragma intrinsic(__emulu)
 static NPY_INLINE uint64_t _umul128(uint64_t a, uint64_t b, uint64_t *high) {
index cfd9aacb4927a0749bba949a99b21767b72d58e8..a1642f9d03e59081bc48cddacc10a71fe6f7c02c 100644 (file)
@@ -1,7 +1,15 @@
 from __future__ import annotations
 
 import sys
-from typing import Any, overload, Sequence, TYPE_CHECKING, Union, TypeVar
+from typing import (
+    Any,
+    overload,
+    Sequence,
+    TYPE_CHECKING,
+    Union,
+    TypeVar,
+    Generic,
+)
 
 from numpy import (
     ndarray,
@@ -47,7 +55,8 @@ if TYPE_CHECKING or HAVE_PROTOCOL:
     class _SupportsArray(Protocol[_DType_co]):
         def __array__(self) -> ndarray[Any, _DType_co]: ...
 else:
-    _SupportsArray = Any
+    class _SupportsArray(Generic[_DType_co]):
+        pass
 
 # TODO: Wait for support for recursive types
 _NestedSequence = Union[
index 636e2209b45f62cb811abd03629dbb34725ade43..9864f46d5e1fe3d6b1e56754a1c50e9e41140db5 100644 (file)
@@ -67,6 +67,8 @@ from ._char_codes import (
     _ObjectCodes,
 )
 
+_DType_co = TypeVar("_DType_co", covariant=True, bound=np.dtype)
+
 _DTypeLikeNested = Any  # TODO: wait for support for recursive types
 
 if TYPE_CHECKING or HAVE_PROTOCOL:
@@ -82,7 +84,6 @@ if TYPE_CHECKING or HAVE_PROTOCOL:
         itemsize: int
         aligned: bool
 
-    _DType_co = TypeVar("_DType_co", covariant=True, bound=np.dtype)
 
     # A protocol for anything with the dtype attribute
     class _SupportsDType(Protocol[_DType_co]):
diff --git a/numpy/typing/tests/data/reveal/nditer.py b/numpy/typing/tests/data/reveal/nditer.py
new file mode 100644 (file)
index 0000000..de2a4b5
--- /dev/null
@@ -0,0 +1,19 @@
+import copy
+import numpy as np
+
+nditer_obj: np.nditer
+
+with nditer_obj as context:
+    reveal_type(context)   # E: numpy.nditer
+
+reveal_type(len(nditer_obj))  # E: builtins.int
+reveal_type(copy.copy(nditer_obj))  # E: numpy.nditer
+reveal_type(next(nditer_obj))  # E: Any
+reveal_type(iter(nditer_obj))  # E: typing.Iterator[Any]
+reveal_type(nditer_obj[1])  # E: Any
+reveal_type(nditer_obj[1:5])  # E: Any
+
+nditer_obj[1] = 1
+nditer_obj[1:5] = 1
+del nditer_obj[1]
+del nditer_obj[1:5]
diff --git a/numpy/typing/tests/test_typing_extensions.py b/numpy/typing/tests/test_typing_extensions.py
new file mode 100644 (file)
index 0000000..f59f222
--- /dev/null
@@ -0,0 +1,35 @@
+"""Tests for the optional typing-extensions dependency."""
+
+import sys
+import textwrap
+import subprocess
+
+CODE = textwrap.dedent(r"""
+    import sys
+    import importlib
+
+    assert "typing_extensions" not in sys.modules
+    assert "numpy.typing" not in sys.modules
+
+    # Importing `typing_extensions` will now raise an `ImportError`
+    sys.modules["typing_extensions"] = None
+    assert importlib.import_module("numpy.typing")
+""")
+
+
+def test_no_typing_extensions() -> None:
+    """Import `numpy.typing` in the absence of typing-extensions.
+
+    Notes
+    -----
+    Ideally, we'd just run the normal typing tests in an environment where
+    typing-extensions is not installed, but unfortunatelly this is currently
+    impossible as it is an indirect hard dependency of pytest.
+
+    """
+    p = subprocess.run([sys.executable, '-c', CODE], capture_output=True)
+    if p.returncode:
+        raise AssertionError(
+            f"Non-zero return code: {p.returncode!r}\n\n{p.stderr.decode()}"
+        )
+
index c7ee86839e4fe69c7f711c1e446423b902a0e926..572e9d8f6a24477091885f1b45f518f558ac1fa4 100644 (file)
@@ -38,7 +38,7 @@ from paver.easy import Bunch, options, task, sh
 #-----------------------------------
 
 # Path to the release notes
-RELEASE_NOTES = 'doc/source/release/1.21.1-notes.rst'
+RELEASE_NOTES = 'doc/source/release/1.21.2-notes.rst'
 
 
 #-------------------------------------------------------
index 14f275e97bbb8b0367e529065b795f3ed3eae5b0..941c8fa8cdcc93a783f9b19b7e58cae8f4be606f 100644 (file)
@@ -4,7 +4,7 @@ requires = [
     "packaging==20.5; platform_machine=='arm64'",  # macos M1
     "setuptools<49.2.0",
     "wheel==0.36.2",
-    "Cython>=0.29.21,<3.0",  # Note: keep in sync with tools/cythonize.py
+    "Cython>=0.29.24,<3.0",  # Note: keep in sync with tools/cythonize.py
 ]
 
 
index 452ccbc64c5a05198bd5af229126e07c778e211f..855fd715755ee6da8900e4c38d773b26f7f9c838 100755 (executable)
@@ -474,9 +474,24 @@ def build_project(args):
             '--single-version-externally-managed',
             '--record=' + dst_dir + 'tmp_install_log.txt']
 
-    from distutils.sysconfig import get_python_lib
-    site_dir = get_python_lib(prefix=dst_dir, plat_specific=True)
-    site_dir_noarch = get_python_lib(prefix=dst_dir, plat_specific=False)
+    py_v_s = sysconfig.get_config_var('py_version_short')
+    platlibdir = getattr(sys, 'platlibdir', '')  # Python3.9+
+    site_dir_template = os.path.normpath(sysconfig.get_path(
+        'platlib', expand=False
+    ))
+    site_dir = site_dir_template.format(platbase=dst_dir,
+                                        py_version_short=py_v_s,
+                                        platlibdir=platlibdir,
+                                        base=dst_dir,
+                                        )
+    noarch_template = os.path.normpath(sysconfig.get_path(
+        'purelib', expand=False
+    ))
+    site_dir_noarch = noarch_template.format(base=dst_dir,
+                                             py_version_short=py_v_s,
+                                             platlibdir=platlibdir,
+                                             )
+
     # easy_install won't install to a path that Python by default cannot see
     # and isn't on the PYTHONPATH.  Plus, it has to exist.
     if not os.path.exists(site_dir):
index 82661046637f36436a37ae19b7e91969fff0e464..ceb9900713cec61e8d7e9af20e050b6eda3fb9e8 100755 (executable)
--- a/setup.py
+++ b/setup.py
@@ -93,6 +93,7 @@ Programming Language :: Python :: 3
 Programming Language :: Python :: 3.7
 Programming Language :: Python :: 3.8
 Programming Language :: Python :: 3.9
+Programming Language :: Python :: 3.10
 Programming Language :: Python :: 3 :: Only
 Programming Language :: Python :: Implementation :: CPython
 Topic :: Software Development
@@ -405,7 +406,7 @@ def setup_package():
         test_suite='pytest',
         version=versioneer.get_version(),
         cmdclass=cmdclass,
-        python_requires='>=3.7',
+        python_requires='>=3.7,<3.11',
         zip_safe=False,
         entry_points={
             'console_scripts': f2py_cmds
index e23ec0333299486ed77e01e91573cfd0eabe892d..1ff36ab7255ba5910aa6ba7ab2942d9e7165c7c0 100644 (file)
@@ -1,4 +1,4 @@
-cython==0.29.23
+cython==0.29.24
 wheel<0.36.3
 setuptools<49.2.0
 hypothesis==6.12.0
index 06cf54c9a41ce9aaaca2bc15bfe438eb96da167c..8370574a11bfe07d452263afc447cf2a19836675 100755 (executable)
@@ -72,7 +72,8 @@ def process_pyx(fromfile, tofile):
         # other fixes in the 0.29 series that are needed even for earlier
         # Python versions.
         # Note: keep in sync with that in pyproject.toml
-        required_version = LooseVersion('0.29.21')
+        # Update for Python 3.10
+        required_version = LooseVersion('0.29.24')
 
         if LooseVersion(cython_version) < required_version:
             cython_path = Cython.__file__