summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--azure-pipelines.yml2
-rw-r--r--doc/source/reference/arrays.scalars.rst8
-rw-r--r--numpy/core/defchararray.py1
-rw-r--r--numpy/core/records.py1
-rw-r--r--numpy/distutils/fcompiler/nv.py2
-rwxr-xr-xnumpy/f2py/crackfortran.py1
-rw-r--r--numpy/lib/npyio.py1
-rw-r--r--numpy/ma/core.py1
-rw-r--r--numpy/ma/extras.py1
-rw-r--r--numpy/typing/_add_docstring.py4
-rw-r--r--numpy/typing/_array_like.py3
-rw-r--r--numpy/typing/_callable.py2
-rw-r--r--numpy/typing/_generic_alias.py5
-rw-r--r--numpy/typing/tests/test_generic_alias.py5
-rwxr-xr-xsetup.py11
15 files changed, 24 insertions, 24 deletions
diff --git a/azure-pipelines.yml b/azure-pipelines.yml
index dd189b8e9..14a59e880 100644
--- a/azure-pipelines.yml
+++ b/azure-pipelines.yml
@@ -19,7 +19,7 @@ stages:
jobs:
- job: Lint
- condition: and(succeeded(), ne(variables['Build.SourceBranch'], 'refs/heads/main')) # skip for PR merges
+ condition: and(succeeded(), eq(variables['Build.Reason'], 'PullRequest'))
pool:
vmImage: 'ubuntu-18.04'
steps:
diff --git a/doc/source/reference/arrays.scalars.rst b/doc/source/reference/arrays.scalars.rst
index 6c9bcb504..abef66692 100644
--- a/doc/source/reference/arrays.scalars.rst
+++ b/doc/source/reference/arrays.scalars.rst
@@ -352,8 +352,8 @@ are also provided.
uint32
uint64
- Alias for the unsigned integer types (one of `numpy.byte`, `numpy.short`,
- `numpy.intc`, `numpy.int_` and `numpy.longlong`) with the specified number
+ Alias for the unsigned integer types (one of `numpy.ubyte`, `numpy.ushort`,
+ `numpy.uintc`, `numpy.uint` and `numpy.ulonglong`) with the specified number
of bits.
Compatible with the C99 ``uint8_t``, ``uint16_t``, ``uint32_t``, and
@@ -371,8 +371,8 @@ are also provided.
.. attribute:: uintp
- Alias for the unsigned integer type (one of `numpy.byte`, `numpy.short`,
- `numpy.intc`, `numpy.int_` and `np.longlong`) that is the same size as a
+ Alias for the unsigned integer type (one of `numpy.ubyte`, `numpy.ushort`,
+ `numpy.uintc`, `numpy.uint` and `np.ulonglong`) that is the same size as a
pointer.
Compatible with the C ``uintptr_t``.
diff --git a/numpy/core/defchararray.py b/numpy/core/defchararray.py
index ab1166ad2..e264fa210 100644
--- a/numpy/core/defchararray.py
+++ b/numpy/core/defchararray.py
@@ -16,7 +16,6 @@ The preferred alias for `defchararray` is `numpy.char`.
"""
import functools
-import sys
from .numerictypes import (
string_, unicode_, integer, int_, object_, bool_, character)
from .numeric import ndarray, compare_chararrays
diff --git a/numpy/core/records.py b/numpy/core/records.py
index 5bd13a698..b3474ad01 100644
--- a/numpy/core/records.py
+++ b/numpy/core/records.py
@@ -33,7 +33,6 @@ Record arrays allow us to access fields as properties::
array([2., 2.])
"""
-import os
import warnings
from collections import Counter
from contextlib import nullcontext
diff --git a/numpy/distutils/fcompiler/nv.py b/numpy/distutils/fcompiler/nv.py
index 8e9f16835..212f34806 100644
--- a/numpy/distutils/fcompiler/nv.py
+++ b/numpy/distutils/fcompiler/nv.py
@@ -1,5 +1,3 @@
-import sys
-
from numpy.distutils.fcompiler import FCompiler
compilers = ['NVHPCFCompiler']
diff --git a/numpy/f2py/crackfortran.py b/numpy/f2py/crackfortran.py
index 6453bbecb..984bd642b 100755
--- a/numpy/f2py/crackfortran.py
+++ b/numpy/f2py/crackfortran.py
@@ -139,7 +139,6 @@ TODO:
The above may be solved by creating appropriate preprocessor program, for example.
"""
-import io
import sys
import string
import fileinput
diff --git a/numpy/lib/npyio.py b/numpy/lib/npyio.py
index 5780a05bb..c4d625bd3 100644
--- a/numpy/lib/npyio.py
+++ b/numpy/lib/npyio.py
@@ -1,4 +1,3 @@
-import sys
import os
import re
import functools
diff --git a/numpy/ma/core.py b/numpy/ma/core.py
index 63d42ecca..4c204cac2 100644
--- a/numpy/ma/core.py
+++ b/numpy/ma/core.py
@@ -40,7 +40,6 @@ from numpy.compat import (
from numpy import expand_dims
from numpy.core.numeric import normalize_axis_tuple
from numpy.core._internal import recursive
-from numpy.compat import pickle
__all__ = [
diff --git a/numpy/ma/extras.py b/numpy/ma/extras.py
index bd5fc2ca3..c139f4640 100644
--- a/numpy/ma/extras.py
+++ b/numpy/ma/extras.py
@@ -33,7 +33,6 @@ from .core import (
import numpy as np
from numpy import ndarray, array as nxarray
-import numpy.core.umath as umath
from numpy.core.multiarray import normalize_axis_index
from numpy.core.numeric import normalize_axis_tuple
from numpy.lib.function_base import _ureduce
diff --git a/numpy/typing/_add_docstring.py b/numpy/typing/_add_docstring.py
index 34dbdb0c6..56ef41cfd 100644
--- a/numpy/typing/_add_docstring.py
+++ b/numpy/typing/_add_docstring.py
@@ -114,7 +114,7 @@ add_newdoc('DTypeLike', 'typing.Union[...]',
add_newdoc('NDArray', repr(NDArray),
"""
A :term:`generic <generic type>` version of
- `np.ndarray[Any, np.dtype[~ScalarType]] <numpy.ndarray>`.
+ `np.ndarray[Any, np.dtype[+ScalarType]] <numpy.ndarray>`.
Can be used during runtime for typing arrays with a given dtype
and unspecified shape.
@@ -127,7 +127,7 @@ add_newdoc('NDArray', repr(NDArray),
>>> import numpy.typing as npt
>>> print(npt.NDArray)
- numpy.ndarray[typing.Any, numpy.dtype[~ScalarType]]
+ numpy.ndarray[typing.Any, numpy.dtype[+ScalarType]]
>>> print(npt.NDArray[np.float64])
numpy.ndarray[typing.Any, numpy.dtype[numpy.float64]]
diff --git a/numpy/typing/_array_like.py b/numpy/typing/_array_like.py
index 9f57b2295..2283c98d7 100644
--- a/numpy/typing/_array_like.py
+++ b/numpy/typing/_array_like.py
@@ -1,7 +1,7 @@
from __future__ import annotations
import sys
-from typing import Any, overload, Sequence, TYPE_CHECKING, Union, TypeVar
+from typing import Any, Sequence, TYPE_CHECKING, Union, TypeVar
from numpy import (
ndarray,
@@ -20,7 +20,6 @@ from numpy import (
str_,
bytes_,
)
-from ._dtype_like import DTypeLike
if sys.version_info >= (3, 8):
from typing import Protocol
diff --git a/numpy/typing/_callable.py b/numpy/typing/_callable.py
index d9cb0f157..8f838f1ae 100644
--- a/numpy/typing/_callable.py
+++ b/numpy/typing/_callable.py
@@ -43,11 +43,9 @@ from ._scalars import (
_BoolLike_co,
_IntLike_co,
_FloatLike_co,
- _ComplexLike_co,
_NumberLike_co,
)
from . import NBitBase
-from ._array_like import ArrayLike
from ._generic_alias import NDArray
if sys.version_info >= (3, 8):
diff --git a/numpy/typing/_generic_alias.py b/numpy/typing/_generic_alias.py
index f98fca62e..68523827a 100644
--- a/numpy/typing/_generic_alias.py
+++ b/numpy/typing/_generic_alias.py
@@ -63,7 +63,8 @@ def _reconstruct_alias(alias: _T, parameters: Iterator[TypeVar]) -> _T:
elif isinstance(i, _GenericAlias):
value = _reconstruct_alias(i, parameters)
elif hasattr(i, "__parameters__"):
- value = i[next(parameters)]
+ prm_tup = tuple(next(parameters) for _ in i.__parameters__)
+ value = i[prm_tup]
else:
value = i
args.append(value)
@@ -195,7 +196,7 @@ if sys.version_info >= (3, 9):
else:
_GENERIC_ALIAS_TYPE = (_GenericAlias,)
-ScalarType = TypeVar("ScalarType", bound=np.generic)
+ScalarType = TypeVar("ScalarType", bound=np.generic, covariant=True)
if TYPE_CHECKING:
NDArray = np.ndarray[Any, np.dtype[ScalarType]]
diff --git a/numpy/typing/tests/test_generic_alias.py b/numpy/typing/tests/test_generic_alias.py
index 13072051a..0b9917439 100644
--- a/numpy/typing/tests/test_generic_alias.py
+++ b/numpy/typing/tests/test_generic_alias.py
@@ -10,7 +10,9 @@ import pytest
import numpy as np
from numpy.typing._generic_alias import _GenericAlias
-ScalarType = TypeVar("ScalarType", bound=np.generic)
+ScalarType = TypeVar("ScalarType", bound=np.generic, covariant=True)
+T1 = TypeVar("T1")
+T2 = TypeVar("T2")
DType = _GenericAlias(np.dtype, (ScalarType,))
NDArray = _GenericAlias(np.ndarray, (Any, DType))
@@ -50,6 +52,7 @@ class TestGenericAlias:
("__getitem__", lambda n: n[np.float64]),
("__getitem__", lambda n: n[ScalarType][np.float64]),
("__getitem__", lambda n: n[Union[np.int64, ScalarType]][np.float64]),
+ ("__getitem__", lambda n: n[Union[T1, T2]][np.float32, np.float64]),
("__eq__", lambda n: n == n),
("__ne__", lambda n: n != np.ndarray),
("__dir__", lambda n: dir(n)),
diff --git a/setup.py b/setup.py
index 247dc512a..826610466 100755
--- a/setup.py
+++ b/setup.py
@@ -25,6 +25,7 @@ import subprocess
import textwrap
import warnings
import builtins
+import re
# Python supported version checks. Keep right after stdlib imports to ensure we
@@ -46,8 +47,14 @@ builtins.__NUMPY_SETUP__ = True
# The version components are changed from ints to strings, but only VERSION
# seems to matter outside of this module and it was already a str.
FULLVERSION = versioneer.get_version()
-ISRELEASED = 'dev' not in FULLVERSION
-MAJOR, MINOR, MICRO = FULLVERSION.split('.')[:3]
+
+# Capture the version string:
+# 1.22.0.dev0+ ... -> ISRELEASED == False, VERSION == 1.22.0
+# 1.22.0rc1+ ... -> ISRELEASED == False, VERSION == 1.22.0
+# 1.22.0 ... -> ISRELEASED == True, VERSION == 1.22.0
+# 1.22.0rc1 ... -> ISRELEASED == True, VERSION == 1.22.0
+ISRELEASED = re.search(r'(dev|\+)', FULLVERSION) is None
+MAJOR, MINOR, MICRO = re.match(r'(\d+)\.(\d+)\.(\d+)', FULLVERSION).groups()
VERSION = '{}.{}.{}'.format(MAJOR, MINOR, MICRO)
# The first version not in the `Programming Language :: Python :: ...` classifiers above