summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDongHun Kwak <dh0128.kwak@samsung.com>2020-12-31 09:33:26 +0900
committerDongHun Kwak <dh0128.kwak@samsung.com>2020-12-31 09:33:26 +0900
commit55cc991fcb761f98ed4dfdcaeaff729bee9a7bf9 (patch)
treebefdd09ebb8508918de095a60021b4ca437de997
parent1101483834e74c852752cfc7aad48d30940f0a1a (diff)
downloadpython-numpy-55cc991fcb761f98ed4dfdcaeaff729bee9a7bf9.tar.gz
python-numpy-55cc991fcb761f98ed4dfdcaeaff729bee9a7bf9.tar.bz2
python-numpy-55cc991fcb761f98ed4dfdcaeaff729bee9a7bf9.zip
Imported Upstream version 1.15.3upstream/1.15.3
-rw-r--r--azure-pipelines.yml112
-rw-r--r--doc/changelog/1.15.3-changelog.rst32
-rw-r--r--doc/release/1.15.3-notes.rst49
-rw-r--r--doc/source/release.rst1
-rw-r--r--numpy/core/src/multiarray/arraytypes.c.src8
-rw-r--r--numpy/core/src/multiarray/mapping.c2
-rw-r--r--numpy/core/src/private/npy_config.h15
-rw-r--r--numpy/core/tests/test_memmap.py5
-rw-r--r--numpy/core/tests/test_regression.py5
-rw-r--r--numpy/distutils/misc_util.py5
-rw-r--r--numpy/f2py/tests/test_return_real.py24
-rw-r--r--numpy/f2py/tests/test_semicolon_split.py12
-rw-r--r--numpy/lib/histograms.py8
-rw-r--r--numpy/lib/tests/test_histograms.py17
-rw-r--r--numpy/ma/core.py12
-rw-r--r--numpy/ma/tests/test_core.py24
-rw-r--r--numpy/random/mtrand/mtrand.pyx4
-rw-r--r--numpy/random/tests/test_regression.py22
-rw-r--r--numpy/tests/test_scripts.py1
-rw-r--r--pavement.py4
-rwxr-xr-xsetup.py2
21 files changed, 338 insertions, 26 deletions
diff --git a/azure-pipelines.yml b/azure-pipelines.yml
new file mode 100644
index 000000000..c99b56e37
--- /dev/null
+++ b/azure-pipelines.yml
@@ -0,0 +1,112 @@
+jobs:
+- job: macOS
+ pool:
+ # NOTE: at time of writing, there is a danger
+ # that using an invalid vmIMage string for macOS
+ # image silently redirects to a Windows build on Azure;
+ # for now, use the only image name officially present in
+ # the docs even though i.e., numba uses another in their
+ # azure config for mac os -- Microsoft has indicated
+ # they will patch this issue
+ vmIMage: macOS-10.13
+ steps:
+ # the @0 refers to the (major) version of the *task* on Microsoft's
+ # end, not the order in the build matrix nor anything to do
+ # with version of Python selected
+ - task: UsePythonVersion@0
+ inputs:
+ versionSpec: '3.6'
+ addToPath: true
+ architecture: 'x64'
+ # NOTE: do we have a compelling reason to use older / newer
+ # versions of Xcode toolchain for testing?
+ - script: /bin/bash -c "sudo xcode-select -s /Applications/Xcode_10.app/Contents/Developer"
+ displayName: 'select Xcode version'
+ # NOTE: might be better if we could avoid installing
+ # two C compilers, but with homebrew looks like we're
+ # now stuck getting the full gcc toolchain instead of
+ # just pulling in gfortran
+ - script: brew install gcc
+ displayName: 'make gfortran available on mac os vm'
+ - script: python -m pip install --upgrade pip setuptools wheel
+ displayName: 'Install tools'
+ - script: python -m pip install cython nose pytz pytest
+ displayName: 'Install dependencies; some are optional to avoid test skips'
+ # NOTE: init_dgelsd failed init issue with current ACCELERATE /
+ # LAPACK configuration on Azure macos image; at the time of writing
+ # this plagues homebrew / macports NumPy builds, but we will
+ # circumvent for now by aggressively disabling acceleration for
+ # macos NumPy builds / tests; ACCELERATE=None on its own is not
+ # sufficient
+ # also, might as well prefer usage of clang over gcc proper
+ # to match likely scenario on many user mac machines
+ - script: python setup.py build -j 4 install
+ displayName: 'Build NumPy'
+ env:
+ BLAS: None
+ LAPACK: None
+ ATLAS: None
+ ACCELERATE: None
+ CC: /usr/bin/clang
+ - script: python runtests.py --mode=full -- -rsx --junitxml=junit/test-results.xml
+ displayName: 'Run Full NumPy Test Suite'
+ - task: PublishTestResults@2
+ inputs:
+ testResultsFiles: '**/test-*.xml'
+ testRunTitle: 'Publish test results for Python $(python.version)'
+- job: Windows
+ pool:
+ vmIMage: 'VS2017-Win2016'
+ strategy:
+ maxParallel: 6
+ matrix:
+ Python36-32bit-fast:
+ PYTHON_VERSION: '3.6'
+ PYTHON_ARCH: 'x86'
+ TEST_MODE: fast
+ Python37-32bit-fast:
+ PYTHON_VERSION: '3.7'
+ PYTHON_ARCH: 'x86'
+ TEST_MODE: fast
+ Python27-64bit-fast:
+ PYTHON_VERSION: '2.7'
+ PYTHON_ARCH: 'x64'
+ TEST_MODE: fast
+ Python35-64bit-full:
+ PYTHON_VERSION: '3.5'
+ PYTHON_ARCH: 'x64'
+ TEST_MODE: full
+ Python36-64bit-full:
+ PYTHON_VERSION: '3.6'
+ PYTHON_ARCH: 'x64'
+ TEST_MODE: full
+ Python37-64bit-full:
+ PYTHON_VERSION: '3.7'
+ PYTHON_ARCH: 'x64'
+ TEST_MODE: full
+ steps:
+ - task: UsePythonVersion@0
+ inputs:
+ versionSpec: $(PYTHON_VERSION)
+ addToPath: true
+ architecture: $(PYTHON_ARCH)
+ # as noted by numba project, currently need
+ # specific VC install for Python 2.7
+ # NOTE: had some issues splitting powershell
+ # command into bits and / or using condition
+ # directive, so squeezing operation to a single
+ # line for now
+ - powershell: if ($env:PYTHON_VERSION -eq 2.7) {$wc = New-Object net.webclient; $wc.Downloadfile("https://download.microsoft.com/download/7/9/6/796EF2E4-801B-4FC4-AB28-B59FBF6D907B/VCForPython27.msi", "VCForPython27.msi"); Start-Process "VCForPython27.msi" /qn -Wait}
+ displayName: 'Install VC 9.0'
+ - script: python -m pip install --upgrade pip setuptools wheel
+ displayName: 'Install tools'
+ - script: python -m pip install cython nose pytz pytest
+ displayName: 'Install dependencies; some are optional to avoid test skips'
+ # NOTE: for Windows builds it seems much more tractable to use runtests.py
+ # vs. manual setup.py and then runtests.py for testing only
+ - script: python runtests.py --show-build-log --mode=$(TEST_MODE) -- -rsx --junitxml=junit/test-results.xml
+ displayName: 'Build NumPy & Run Full NumPy Test Suite'
+ - task: PublishTestResults@2
+ inputs:
+ testResultsFiles: '**/test-*.xml'
+ testRunTitle: 'Publish test results for Python $(python.version)'
diff --git a/doc/changelog/1.15.3-changelog.rst b/doc/changelog/1.15.3-changelog.rst
new file mode 100644
index 000000000..9e03df454
--- /dev/null
+++ b/doc/changelog/1.15.3-changelog.rst
@@ -0,0 +1,32 @@
+
+Contributors
+============
+
+A total of 7 people contributed to this release. People with a "+" by their
+names contributed a patch for the first time.
+
+* Allan Haldane
+* Charles Harris
+* Jeroen Demeyer
+* Kevin Sheppard
+* Matthew Bowden +
+* Matti Picus
+* Tyler Reddy
+
+Pull requests merged
+====================
+
+A total of 12 pull requests were merged for this release.
+
+* `#12080 <https://github.com/numpy/numpy/pull/12080>`__: MAINT: Blacklist some MSVC complex functions.
+* `#12083 <https://github.com/numpy/numpy/pull/12083>`__: TST: Add azure CI testing to 1.15.x branch.
+* `#12084 <https://github.com/numpy/numpy/pull/12084>`__: BUG: test_path() now uses Path.resolve()
+* `#12085 <https://github.com/numpy/numpy/pull/12085>`__: TST, MAINT: Fix some failing tests on azure-pipelines mac and...
+* `#12187 <https://github.com/numpy/numpy/pull/12187>`__: BUG: Fix memory leak in mapping.c
+* `#12188 <https://github.com/numpy/numpy/pull/12188>`__: BUG: Allow boolean subtract in histogram
+* `#12189 <https://github.com/numpy/numpy/pull/12189>`__: BUG: Fix in-place permutation
+* `#12190 <https://github.com/numpy/numpy/pull/12190>`__: BUG: limit default for get_num_build_jobs() to 8
+* `#12191 <https://github.com/numpy/numpy/pull/12191>`__: BUG: OBJECT_to_* should check for errors
+* `#12192 <https://github.com/numpy/numpy/pull/12192>`__: DOC: Prepare for NumPy 1.15.3 release.
+* `#12237 <https://github.com/numpy/numpy/pull/12237>`__: BUG: Fix MaskedArray fill_value type conversion.
+* `#12238 <https://github.com/numpy/numpy/pull/12238>`__: TST: Backport azure-pipeline testing fixes for Mac
diff --git a/doc/release/1.15.3-notes.rst b/doc/release/1.15.3-notes.rst
new file mode 100644
index 000000000..753eecec9
--- /dev/null
+++ b/doc/release/1.15.3-notes.rst
@@ -0,0 +1,49 @@
+==========================
+NumPy 1.15.3 Release Notes
+==========================
+
+This is a bugfix release for bugs and regressions reported following the 1.15.2
+release. The Python versions supported by this release are 2.7, 3.4-3.7. The
+wheels are linked with OpenBLAS v0.3.0, which should fix some of the linalg
+problems reported for NumPy 1.14.
+
+Compatibility Note
+==================
+
+The NumPy 1.15.x OS X wheels released on PyPI no longer contain 32-bit
+binaries. That will also be the case in future releases. See
+`#11625 <https://github.com/numpy/numpy/issues/11625>`__ for the related
+discussion. Those needing 32-bit support should look elsewhere or build
+from source.
+
+Contributors
+============
+
+A total of 7 people contributed to this release. People with a "+" by their
+names contributed a patch for the first time.
+
+* Allan Haldane
+* Charles Harris
+* Jeroen Demeyer
+* Kevin Sheppard
+* Matthew Bowden +
+* Matti Picus
+* Tyler Reddy
+
+Pull requests merged
+====================
+
+A total of 12 pull requests were merged for this release.
+
+* `#12080 <https://github.com/numpy/numpy/pull/12080>`__: MAINT: Blacklist some MSVC complex functions.
+* `#12083 <https://github.com/numpy/numpy/pull/12083>`__: TST: Add azure CI testing to 1.15.x branch.
+* `#12084 <https://github.com/numpy/numpy/pull/12084>`__: BUG: test_path() now uses Path.resolve()
+* `#12085 <https://github.com/numpy/numpy/pull/12085>`__: TST, MAINT: Fix some failing tests on azure-pipelines mac and...
+* `#12187 <https://github.com/numpy/numpy/pull/12187>`__: BUG: Fix memory leak in mapping.c
+* `#12188 <https://github.com/numpy/numpy/pull/12188>`__: BUG: Allow boolean subtract in histogram
+* `#12189 <https://github.com/numpy/numpy/pull/12189>`__: BUG: Fix in-place permutation
+* `#12190 <https://github.com/numpy/numpy/pull/12190>`__: BUG: limit default for get_num_build_jobs() to 8
+* `#12191 <https://github.com/numpy/numpy/pull/12191>`__: BUG: OBJECT_to_* should check for errors
+* `#12192 <https://github.com/numpy/numpy/pull/12192>`__: DOC: Prepare for NumPy 1.15.3 release.
+* `#12237 <https://github.com/numpy/numpy/pull/12237>`__: BUG: Fix MaskedArray fill_value type conversion.
+* `#12238 <https://github.com/numpy/numpy/pull/12238>`__: TST: Backport azure-pipeline testing fixes for Mac
diff --git a/doc/source/release.rst b/doc/source/release.rst
index 637391010..cfd77e853 100644
--- a/doc/source/release.rst
+++ b/doc/source/release.rst
@@ -2,6 +2,7 @@
Release Notes
*************
+.. include:: ../release/1.15.3-notes.rst
.. include:: ../release/1.15.2-notes.rst
.. include:: ../release/1.15.1-notes.rst
.. include:: ../release/1.15.0-notes.rst
diff --git a/numpy/core/src/multiarray/arraytypes.c.src b/numpy/core/src/multiarray/arraytypes.c.src
index d622effe6..1055f6adc 100644
--- a/numpy/core/src/multiarray/arraytypes.c.src
+++ b/numpy/core/src/multiarray/arraytypes.c.src
@@ -1489,10 +1489,14 @@ OBJECT_to_@TOTYPE@(void *input, void *output, npy_intp n,
for (i = 0; i < n; i++, ip++, op += skip) {
if (*ip == NULL) {
- @TOTYPE@_setitem(Py_False, op, aop);
+ if (@TOTYPE@_setitem(Py_False, op, aop) < 0) {
+ return;
+ }
}
else {
- @TOTYPE@_setitem(*ip, op, aop);
+ if (@TOTYPE@_setitem(*ip, op, aop) < 0) {
+ return;
+ }
}
}
}
diff --git a/numpy/core/src/multiarray/mapping.c b/numpy/core/src/multiarray/mapping.c
index 246dbefd5..57b8f15c2 100644
--- a/numpy/core/src/multiarray/mapping.c
+++ b/numpy/core/src/multiarray/mapping.c
@@ -1127,8 +1127,8 @@ array_boolean_subscript(PyArrayObject *self,
1, &size, PyArray_STRIDES(ret), PyArray_BYTES(ret),
PyArray_FLAGS(self), (PyObject *)self, (PyObject *)tmp);
+ Py_DECREF(tmp);
if (ret == NULL) {
- Py_DECREF(tmp);
return NULL;
}
}
diff --git a/numpy/core/src/private/npy_config.h b/numpy/core/src/private/npy_config.h
index 107b3cb5b..eabcf99da 100644
--- a/numpy/core/src/private/npy_config.h
+++ b/numpy/core/src/private/npy_config.h
@@ -45,7 +45,7 @@
#endif
-#if defined(_MSC_VER) && (_MSC_VER == 1900)
+#if defined(_MSC_VER) && (_MSC_VER >= 1900)
#undef HAVE_CASIN
#undef HAVE_CASINF
@@ -60,6 +60,19 @@
#undef HAVE_CATANHF
#undef HAVE_CATANHL
+#undef HAVE_CSQRT
+#undef HAVE_CSQRTF
+#undef HAVE_CSQRTL
+#undef HAVE_CLOG
+#undef HAVE_CLOGF
+#undef HAVE_CLOGL
+#undef HAVE_CACOS
+#undef HAVE_CACOSF
+#undef HAVE_CACOSL
+#undef HAVE_CACOSH
+#undef HAVE_CACOSHF
+#undef HAVE_CACOSHL
+
#endif
/* MSVC _hypot messes with fp precision mode on 32-bit, see gh-9567 */
diff --git a/numpy/core/tests/test_memmap.py b/numpy/core/tests/test_memmap.py
index 59ca28324..990d0ae26 100644
--- a/numpy/core/tests/test_memmap.py
+++ b/numpy/core/tests/test_memmap.py
@@ -81,7 +81,10 @@ class TestMemmap(object):
tmpname = mktemp('', 'mmap', dir=self.tempdir)
fp = memmap(Path(tmpname), dtype=self.dtype, mode='w+',
shape=self.shape)
- abspath = os.path.realpath(os.path.abspath(tmpname))
+ # os.path.realpath does not resolve symlinks on Windows
+ # see: https://bugs.python.org/issue9949
+ # use Path.resolve, just as memmap class does internally
+ abspath = str(Path(tmpname).resolve())
fp[:] = self.data[:]
assert_equal(abspath, str(fp.filename.resolve()))
b = fp[:1]
diff --git a/numpy/core/tests/test_regression.py b/numpy/core/tests/test_regression.py
index 51fe13f5d..26d79468f 100644
--- a/numpy/core/tests/test_regression.py
+++ b/numpy/core/tests/test_regression.py
@@ -2410,3 +2410,8 @@ class TestRegression(object):
v = str(data[['f1']])
if HAS_REFCOUNT:
assert_(base <= sys.getrefcount(s))
+
+ def test_object_casting_errors(self):
+ # gh-11993
+ arr = np.array(['AAAAA', 18465886.0, 18465886.0], dtype=object)
+ assert_raises(TypeError, arr.astype, 'c8')
diff --git a/numpy/distutils/misc_util.py b/numpy/distutils/misc_util.py
index f2d677abe..091114f98 100644
--- a/numpy/distutils/misc_util.py
+++ b/numpy/distutils/misc_util.py
@@ -84,7 +84,9 @@ def get_num_build_jobs():
Get number of parallel build jobs set by the --parallel command line
argument of setup.py
If the command did not receive a setting the environment variable
- NPY_NUM_BUILD_JOBS checked and if that is unset it returns 1.
+ NPY_NUM_BUILD_JOBS is checked. If that is unset, return the number of
+ processors on the system, with a maximum of 8 (to prevent
+ overloading the system if there a lot of CPUs).
Returns
-------
@@ -97,6 +99,7 @@ def get_num_build_jobs():
cpu_count = len(os.sched_getaffinity(0))
except AttributeError:
cpu_count = multiprocessing.cpu_count()
+ cpu_count = min(cpu_count, 8)
envjobs = int(os.environ.get("NPY_NUM_BUILD_JOBS", cpu_count))
dist = get_distribution()
# may be None during configuration
diff --git a/numpy/f2py/tests/test_return_real.py b/numpy/f2py/tests/test_return_real.py
index fcb13e1e0..315cfe49b 100644
--- a/numpy/f2py/tests/test_return_real.py
+++ b/numpy/f2py/tests/test_return_real.py
@@ -1,5 +1,6 @@
from __future__ import division, absolute_import, print_function
+import platform
import pytest
from numpy import array
@@ -52,6 +53,11 @@ class TestReturnReal(util.F2PyTest):
pass
+
+@pytest.mark.skipif(
+ platform.system() == 'Darwin',
+ reason="Prone to error when run with numpy/f2py/tests on mac os, "
+ "but not when run in isolation")
class TestCReturnReal(TestReturnReal):
suffix = ".pyf"
module_name = "c_ext_return_real"
@@ -85,9 +91,9 @@ end python module c_ext_return_real
"""
@pytest.mark.slow
- def test_all(self):
- for name in "t4,t8,s4,s8".split(","):
- self.check_function(getattr(self.module, name))
+ @pytest.mark.parametrize('name', 't4,t8,s4,s8'.split(','))
+ def test_all(self, name):
+ self.check_function(getattr(self.module, name))
class TestF77ReturnReal(TestReturnReal):
@@ -140,9 +146,9 @@ cf2py intent(out) td
"""
@pytest.mark.slow
- def test_all(self):
- for name in "t0,t4,t8,td,s0,s4,s8,sd".split(","):
- self.check_function(getattr(self.module, name))
+ @pytest.mark.parametrize('name', 't0,t4,t8,td,s0,s4,s8,sd'.split(','))
+ def test_all(self, name):
+ self.check_function(getattr(self.module, name))
class TestF90ReturnReal(TestReturnReal):
@@ -199,6 +205,6 @@ end module f90_return_real
"""
@pytest.mark.slow
- def test_all(self):
- for name in "t0,t4,t8,td,s0,s4,s8,sd".split(","):
- self.check_function(getattr(self.module.f90_return_real, name))
+ @pytest.mark.parametrize('name', 't0,t4,t8,td,s0,s4,s8,sd'.split(','))
+ def test_all(self, name):
+ self.check_function(getattr(self.module.f90_return_real, name))
diff --git a/numpy/f2py/tests/test_semicolon_split.py b/numpy/f2py/tests/test_semicolon_split.py
index 2b0f32727..bcd18c893 100644
--- a/numpy/f2py/tests/test_semicolon_split.py
+++ b/numpy/f2py/tests/test_semicolon_split.py
@@ -1,8 +1,15 @@
from __future__ import division, absolute_import, print_function
+import platform
+import pytest
+
from . import util
from numpy.testing import assert_equal
+@pytest.mark.skipif(
+ platform.system() == 'Darwin',
+ reason="Prone to error when run with numpy/f2py/tests on mac os, "
+ "but not when run in isolation")
class TestMultiline(util.F2PyTest):
suffix = ".pyf"
module_name = "multiline"
@@ -26,6 +33,11 @@ end python module {module}
def test_multiline(self):
assert_equal(self.module.foo(), 42)
+
+@pytest.mark.skipif(
+ platform.system() == 'Darwin',
+ reason="Prone to error when run with numpy/f2py/tests on mac os, "
+ "but not when run in isolation")
class TestCallstatement(util.F2PyTest):
suffix = ".pyf"
module_name = "callstatement"
diff --git a/numpy/lib/histograms.py b/numpy/lib/histograms.py
index 47ee92928..209b55867 100644
--- a/numpy/lib/histograms.py
+++ b/numpy/lib/histograms.py
@@ -220,6 +220,14 @@ _hist_bin_selectors = {'auto': _hist_bin_auto,
def _ravel_and_check_weights(a, weights):
""" Check a and weights have matching shapes, and ravel both """
a = np.asarray(a)
+
+ # Ensure that the array is a "subtractable" dtype
+ if a.dtype == np.bool_:
+ warnings.warn("Converting input from {} to {} for compatibility."
+ .format(a.dtype, np.uint8),
+ RuntimeWarning, stacklevel=2)
+ a = a.astype(np.uint8)
+
if weights is not None:
weights = np.asarray(weights)
if weights.shape != a.shape:
diff --git a/numpy/lib/tests/test_histograms.py b/numpy/lib/tests/test_histograms.py
index 561f5f938..a71060a46 100644
--- a/numpy/lib/tests/test_histograms.py
+++ b/numpy/lib/tests/test_histograms.py
@@ -141,6 +141,23 @@ class TestHistogram(object):
counts_hist, xedges, yedges = np.histogram2d(x, y, bins=100)
assert_equal(counts_hist.sum(), 3.)
+ def test_bool_conversion(self):
+ # gh-12107
+ # Reference integer histogram
+ a = np.array([1, 1, 0], dtype=np.uint8)
+ int_hist, int_edges = np.histogram(a)
+
+ # Should raise an warning on booleans
+ # Ensure that the histograms are equivalent, need to suppress
+ # the warnings to get the actual outputs
+ with suppress_warnings() as sup:
+ rec = sup.record(RuntimeWarning, 'Converting input from .*')
+ hist, edges = np.histogram([True, True, False])
+ # A warning should be issued
+ assert_equal(len(rec), 1)
+ assert_array_equal(hist, int_hist)
+ assert_array_equal(edges, int_edges)
+
def test_weights(self):
v = np.random.rand(100)
w = np.ones(100) * 5
diff --git a/numpy/ma/core.py b/numpy/ma/core.py
index 091ab4e20..52039bd97 100644
--- a/numpy/ma/core.py
+++ b/numpy/ma/core.py
@@ -3010,11 +3010,13 @@ class MaskedArray(ndarray):
except (TypeError, AttributeError):
# When _mask.shape is not writable (because it's a void)
pass
- # Finalize the fill_value for structured arrays
- if self.dtype.names:
- if self._fill_value is None:
- self._fill_value = _check_fill_value(None, self.dtype)
- return
+
+ # Finalize the fill_value
+ if self._fill_value is not None:
+ self._fill_value = _check_fill_value(self._fill_value, self.dtype)
+ elif self.dtype.names is not None:
+ # Finalize the default fill_value for structured arrays
+ self._fill_value = _check_fill_value(None, self.dtype)
def __array_wrap__(self, obj, context=None):
"""
diff --git a/numpy/ma/tests/test_core.py b/numpy/ma/tests/test_core.py
index 24657bd1e..e935b65e3 100644
--- a/numpy/ma/tests/test_core.py
+++ b/numpy/ma/tests/test_core.py
@@ -4987,7 +4987,7 @@ def test_ufunc_with_out_varied():
assert_equal(res_pos.data, expected.data)
-def test_astype():
+def test_astype_mask_ordering():
descr = [('v', int, 3), ('x', [('y', float)])]
x = array([
[([1, 2, 3], (1.0,)), ([1, 2, 3], (2.0,))],
@@ -5017,3 +5017,25 @@ def test_astype():
x_f2 = np.array(x, dtype=x.dtype, order='F', subok=True)
assert_(x_f2.flags.f_contiguous)
assert_(x_f2.mask.flags.f_contiguous)
+
+
+dts = [np.dtype(dt_) for dt_ in '?bhilqBHILQefdgFD']
+ids = [dt_.char for dt_ in dts]
+
+@pytest.mark.parametrize('dt1', dts, ids=ids)
+@pytest.mark.parametrize('dt2', dts, ids=ids)
+@pytest.mark.filterwarnings('ignore::numpy.ComplexWarning')
+def test_astype_basic(dt1, dt2):
+ # See gh-12070
+ src = np.ma.array(ones(3, dt1), fill_value=1)
+ dst = src.astype(dt2)
+
+ assert_(src.fill_value == 1)
+ assert_(src.dtype == dt1)
+ assert_(src.fill_value.dtype == dt1)
+
+ assert_(dst.fill_value == 1)
+ assert_(dst.dtype == dt2)
+ assert_(dst.fill_value.dtype == dt2)
+
+ assert_equal(src, dst)
diff --git a/numpy/random/mtrand/mtrand.pyx b/numpy/random/mtrand/mtrand.pyx
index b45b3146f..95b0accdc 100644
--- a/numpy/random/mtrand/mtrand.pyx
+++ b/numpy/random/mtrand/mtrand.pyx
@@ -4908,8 +4908,8 @@ cdef class RandomState:
# shuffle has fast-path for 1-d
if arr.ndim == 1:
- # must return a copy
- if arr is x:
+ # Return a copy if same memory
+ if np.may_share_memory(arr, x):
arr = np.array(arr)
self.shuffle(arr)
return arr
diff --git a/numpy/random/tests/test_regression.py b/numpy/random/tests/test_regression.py
index 3b4b4ed40..ca9bbbc71 100644
--- a/numpy/random/tests/test_regression.py
+++ b/numpy/random/tests/test_regression.py
@@ -133,3 +133,25 @@ class TestRegression(object):
# Force Garbage Collection - should not segfault.
import gc
gc.collect()
+
+ def test_permutation_subclass(self):
+ class N(np.ndarray):
+ pass
+
+ np.random.seed(1)
+ orig = np.arange(3).view(N)
+ perm = np.random.permutation(orig)
+ assert_array_equal(perm, np.array([0, 2, 1]))
+ assert_array_equal(orig, np.arange(3).view(N))
+
+ class M(object):
+ a = np.arange(5)
+
+ def __array__(self):
+ return self.a
+
+ np.random.seed(1)
+ m = M()
+ perm = np.random.permutation(m)
+ assert_array_equal(perm, np.array([2, 1, 4, 0, 3]))
+ assert_array_equal(m.__array__(), np.arange(5))
diff --git a/numpy/tests/test_scripts.py b/numpy/tests/test_scripts.py
index ee09390c7..49ace6d38 100644
--- a/numpy/tests/test_scripts.py
+++ b/numpy/tests/test_scripts.py
@@ -60,6 +60,7 @@ def run_command(cmd, check_code=True):
@pytest.mark.skipif(is_inplace, reason="Cannot test f2py command inplace")
+@pytest.mark.xfail(reason="Test is unreliable")
def test_f2py():
# test that we can run f2py script
if sys.platform == 'win32':
diff --git a/pavement.py b/pavement.py
index 2fdc77deb..c9a8f8f00 100644
--- a/pavement.py
+++ b/pavement.py
@@ -95,10 +95,10 @@ finally:
#-----------------------------------
# Source of the release notes
-RELEASE_NOTES = 'doc/release/1.15.2-notes.rst'
+RELEASE_NOTES = 'doc/release/1.15.3-notes.rst'
# Start/end of the log (from git)
-LOG_START = 'v1.15.1'
+LOG_START = 'v1.15.2'
LOG_END = 'maintenance/1.15.x'
diff --git a/setup.py b/setup.py
index 1642e6a57..c48c4429c 100755
--- a/setup.py
+++ b/setup.py
@@ -64,7 +64,7 @@ Operating System :: MacOS
MAJOR = 1
MINOR = 15
-MICRO = 2
+MICRO = 3
ISRELEASED = True
VERSION = '%d.%d.%d' % (MAJOR, MINOR, MICRO)