summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--numpy/__init__.py6
-rw-r--r--numpy/core/_add_newdocs.py2
-rw-r--r--numpy/core/numeric.py2
-rw-r--r--numpy/lib/tests/test_io.py5
-rw-r--r--numpy/typing/tests/data/mypy.ini1
-rw-r--r--numpy/typing/tests/test_typing.py89
-rw-r--r--pavement.py48
7 files changed, 75 insertions, 78 deletions
diff --git a/numpy/__init__.py b/numpy/__init__.py
index a242bb7df..7dadb6491 100644
--- a/numpy/__init__.py
+++ b/numpy/__init__.py
@@ -109,8 +109,9 @@ Exceptions to this rule are documented.
import sys
import warnings
-from ._globals import ModuleDeprecationWarning, VisibleDeprecationWarning
-from ._globals import _NoValue
+from ._globals import (
+ ModuleDeprecationWarning, VisibleDeprecationWarning, _NoValue
+)
# We first need to detect if we're being called as part of the numpy setup
# procedure itself in a reliable manner.
@@ -397,4 +398,3 @@ else:
from ._version import get_versions
__version__ = get_versions()['version']
del get_versions
-
diff --git a/numpy/core/_add_newdocs.py b/numpy/core/_add_newdocs.py
index 8eb42caf5..6073166a0 100644
--- a/numpy/core/_add_newdocs.py
+++ b/numpy/core/_add_newdocs.py
@@ -821,7 +821,7 @@ add_newdoc('numpy.core.multiarray', 'array',
===== ========= ===================================================
When ``copy=False`` and a copy is made for other reasons, the result is
- the same as if ``copy=True``, with some exceptions for `A`, see the
+ the same as if ``copy=True``, with some exceptions for 'A', see the
Notes section. The default order is 'K'.
subok : bool, optional
If True, then sub-classes will be passed-through, otherwise
diff --git a/numpy/core/numeric.py b/numpy/core/numeric.py
index c95c48d71..e776bd43b 100644
--- a/numpy/core/numeric.py
+++ b/numpy/core/numeric.py
@@ -299,7 +299,7 @@ def full(shape, fill_value, dtype=None, order='C', *, like=None):
Fill value.
dtype : data-type, optional
The desired data-type for the array The default, None, means
- `np.array(fill_value).dtype`.
+ ``np.array(fill_value).dtype``.
order : {'C', 'F'}, optional
Whether to store multidimensional data in C- or Fortran-contiguous
(row- or column-wise) order in memory.
diff --git a/numpy/lib/tests/test_io.py b/numpy/lib/tests/test_io.py
index aa4499764..534ab683c 100644
--- a/numpy/lib/tests/test_io.py
+++ b/numpy/lib/tests/test_io.py
@@ -580,7 +580,7 @@ class TestSaveTxt:
memoryerror_raised.value = False
try:
# The test takes at least 6GB of memory, writes a file larger
- # than 4GB
+ # than 4GB. This tests the ``allowZip64`` kwarg to ``zipfile``
test_data = np.asarray([np.random.rand(
np.random.randint(50,100),4)
for i in range(800000)], dtype=object)
@@ -599,6 +599,9 @@ class TestSaveTxt:
p.join()
if memoryerror_raised.value:
raise MemoryError("Child process raised a MemoryError exception")
+ # -9 indicates a SIGKILL, probably an OOM.
+ if p.exitcode == -9:
+ pytest.xfail("subprocess got a SIGKILL, apparently free memory was not sufficient")
assert p.exitcode == 0
class LoadTxtBase:
diff --git a/numpy/typing/tests/data/mypy.ini b/numpy/typing/tests/data/mypy.ini
index 35cfbec89..548f76261 100644
--- a/numpy/typing/tests/data/mypy.ini
+++ b/numpy/typing/tests/data/mypy.ini
@@ -1,5 +1,6 @@
[mypy]
plugins = numpy.typing.mypy_plugin
+show_absolute_path = True
[mypy-numpy]
ignore_errors = True
diff --git a/numpy/typing/tests/test_typing.py b/numpy/typing/tests/test_typing.py
index 18520a757..324312a92 100644
--- a/numpy/typing/tests/test_typing.py
+++ b/numpy/typing/tests/test_typing.py
@@ -25,15 +25,48 @@ REVEAL_DIR = os.path.join(DATA_DIR, "reveal")
MYPY_INI = os.path.join(DATA_DIR, "mypy.ini")
CACHE_DIR = os.path.join(DATA_DIR, ".mypy_cache")
+#: A dictionary with file names as keys and lists of the mypy stdout as values.
+#: To-be populated by `run_mypy`.
+OUTPUT_MYPY: Dict[str, List[str]] = {}
+
+
+def _key_func(key: str) -> str:
+ """Split at the first occurance of the ``:`` character.
+
+ Windows drive-letters (*e.g.* ``C:``) are ignored herein.
+ """
+ drive, tail = os.path.splitdrive(key)
+ return os.path.join(drive, tail.split(":", 1)[0])
+
@pytest.mark.slow
@pytest.mark.skipif(NO_MYPY, reason="Mypy is not installed")
-@pytest.fixture(scope="session", autouse=True)
-def clear_cache() -> None:
- """Clears the mypy cache before running any of the typing tests."""
+@pytest.fixture(scope="module", autouse=True)
+def run_mypy() -> None:
+ """Clears the cache and run mypy before running any of the typing tests.
+
+ The mypy results are cached in `OUTPUT_MYPY` for further use.
+
+ """
if os.path.isdir(CACHE_DIR):
shutil.rmtree(CACHE_DIR)
+ for directory in (PASS_DIR, REVEAL_DIR, FAIL_DIR):
+ # Run mypy
+ stdout, stderr, _ = api.run([
+ "--config-file",
+ MYPY_INI,
+ "--cache-dir",
+ CACHE_DIR,
+ directory,
+ ])
+ assert not stderr, directory
+ stdout = stdout.replace('*', '')
+
+ # Parse the output
+ iterator = itertools.groupby(stdout.split("\n"), key=_key_func)
+ OUTPUT_MYPY.update((k, list(v)) for k, v in iterator if k)
+
def get_test_cases(directory):
for root, _, files in os.walk(directory):
@@ -54,15 +87,9 @@ def get_test_cases(directory):
@pytest.mark.skipif(NO_MYPY, reason="Mypy is not installed")
@pytest.mark.parametrize("path", get_test_cases(PASS_DIR))
def test_success(path):
- stdout, stderr, exitcode = api.run([
- "--config-file",
- MYPY_INI,
- "--cache-dir",
- CACHE_DIR,
- path,
- ])
- assert exitcode == 0, stdout
- assert re.match(r"Success: no issues found in \d+ source files?", stdout.strip())
+ # Alias `OUTPUT_MYPY` so that it appears in the local namespace
+ output_mypy = OUTPUT_MYPY
+ assert path not in output_mypy
@pytest.mark.slow
@@ -71,29 +98,14 @@ def test_success(path):
def test_fail(path):
__tracebackhide__ = True
- stdout, stderr, exitcode = api.run([
- "--config-file",
- MYPY_INI,
- "--cache-dir",
- CACHE_DIR,
- path,
- ])
- assert exitcode != 0
-
with open(path) as fin:
lines = fin.readlines()
errors = defaultdict(lambda: "")
- error_lines = stdout.rstrip("\n").split("\n")
- assert re.match(
- r"Found \d+ errors? in \d+ files? \(checked \d+ source files?\)",
- error_lines[-1].strip(),
- )
- for error_line in error_lines[:-1]:
- error_line = error_line.strip()
- if not error_line:
- continue
+ output_mypy = OUTPUT_MYPY
+ assert path in output_mypy
+ for error_line in output_mypy[path]:
match = re.match(
r"^.+\.py:(?P<lineno>\d+): (error|note): .+$",
error_line,
@@ -215,23 +227,12 @@ def _parse_reveals(file: IO[str]) -> List[str]:
def test_reveal(path):
__tracebackhide__ = True
- stdout, stderr, exitcode = api.run([
- "--config-file",
- MYPY_INI,
- "--cache-dir",
- CACHE_DIR,
- path,
- ])
-
with open(path) as fin:
lines = _parse_reveals(fin)
- stdout_list = stdout.replace('*', '').split("\n")
- for error_line in stdout_list:
- error_line = error_line.strip()
- if not error_line:
- continue
-
+ output_mypy = OUTPUT_MYPY
+ assert path in output_mypy
+ for error_line in output_mypy[path]:
match = re.match(
r"^.+\.py:(?P<lineno>\d+): note: .+$",
error_line,
diff --git a/pavement.py b/pavement.py
index 373354432..66c2cf953 100644
--- a/pavement.py
+++ b/pavement.py
@@ -26,6 +26,7 @@ import os
import sys
import shutil
import hashlib
+import textwrap
# The paver package needs to be installed to run tasks
import paver
@@ -49,25 +50,13 @@ options(installers=Bunch(releasedir="release",
installersdir=os.path.join("release", "installers")),)
-#-----------------------------
-# Generate the release version
-#-----------------------------
+#------------------------
+# Get the release version
+#------------------------
sys.path.insert(0, os.path.dirname(__file__))
try:
- setup_py = __import__("setup")
- FULLVERSION = setup_py.VERSION
- # This is duplicated from setup.py
- if os.path.exists('.git'):
- GIT_REVISION = setup_py.git_version()
- elif os.path.exists('numpy/version.py'):
- # must be a source distribution, use existing version file
- from numpy.version import git_revision as GIT_REVISION
- else:
- GIT_REVISION = "Unknown"
-
- if not setup_py.ISRELEASED:
- FULLVERSION += '.dev0+' + GIT_REVISION[:7]
+ from setup import FULLVERSION
finally:
sys.path.pop(0)
@@ -210,22 +199,25 @@ def write_release_task(options, filename='README'):
with open(notes) as fnotes:
freadme.write(fnotes.read())
- freadme.writelines("""
-Checksums
-=========
+ freadme.writelines(textwrap.dedent(
+ """
+ Checksums
+ =========
-MD5
----
-::
+ MD5
+ ---
+ ::
-""")
+ """))
freadme.writelines([f' {c}\n' for c in compute_md5(idirs)])
- freadme.writelines("""
-SHA256
-------
-::
-""")
+ freadme.writelines(textwrap.dedent(
+ """
+ SHA256
+ ------
+ ::
+
+ """))
freadme.writelines([f' {c}\n' for c in compute_sha256(idirs)])
# generate md file using pandoc before signing