diff -Nru python-numpy-1.14.3/debian/changelog python-numpy-1.14.5/debian/changelog --- python-numpy-1.14.3/debian/changelog 2018-05-29 00:17:49.000000000 +0000 +++ python-numpy-1.14.5/debian/changelog 2018-06-13 13:01:53.000000000 +0000 @@ -1,3 +1,31 @@ +python-numpy (1:1.14.5-1ubuntu1) cosmic; urgency=low + + * Merge from Debian unstable. Remaining changes: + - debian/patches/20_disable-plot-extension.patch + Disable plot_directive extension, and catch ImportErrors when + matplotlib cannot be imported, which allows us to remove + python-matplotlib from dependencies. This is required because + python-numpy is in main, while python-matplotlib is in universe. + + -- Gianfranco Costamagna Wed, 13 Jun 2018 15:01:53 +0200 + +python-numpy (1:1.14.5-1) unstable; urgency=medium + + * New upstream release + + -- Sandro Tosi Tue, 12 Jun 2018 19:33:00 -0400 + +python-numpy (1:1.14.4-1) unstable; urgency=medium + + [ Ondřej Nový ] + * d/control: Remove ancient X-Python-Version field + * d/control: Remove ancient X-Python3-Version field + + [ Sandro Tosi ] + * New upstream release; Closes: #898776 + + -- Sandro Tosi Thu, 07 Jun 2018 21:02:36 -0400 + python-numpy (1:1.14.3-2ubuntu2) cosmic; urgency=medium * Fix alignment issue causing FTBFS on armhf diff -Nru python-numpy-1.14.3/debian/control python-numpy-1.14.5/debian/control --- python-numpy-1.14.3/debian/control 2018-05-09 12:12:59.000000000 +0000 +++ python-numpy-1.14.5/debian/control 2018-06-13 13:01:53.000000000 +0000 @@ -17,6 +17,7 @@ python-all-dev, python3-all-dev, python-docutils, + python3-matplotlib, python-nose (>= 1.0), python3-nose (>= 1.0), python-setuptools, @@ -24,8 +25,6 @@ python3-sphinx, python-tz, python3-tz, -X-Python-Version: >= 2.7 -X-Python3-Version: >= 3.4 Standards-Version: 4.1.4 Vcs-Git: https://salsa.debian.org/python-team/modules/python-numpy.git Vcs-Browser: https://salsa.debian.org/python-team/modules/python-numpy diff -Nru python-numpy-1.14.3/debian/patches/20_disable-plot-extension.patch python-numpy-1.14.5/debian/patches/20_disable-plot-extension.patch --- python-numpy-1.14.3/debian/patches/20_disable-plot-extension.patch 2018-05-09 12:13:13.000000000 +0000 +++ python-numpy-1.14.5/debian/patches/20_disable-plot-extension.patch 2018-06-13 13:01:53.000000000 +0000 @@ -3,10 +3,10 @@ as a dependency. Author: Barry Warsaw Bug-Ubuntu: https://launchpad.net/bugs/664276 -Index: python-numpy-1.14.3-2ubuntu1/doc/source/conf.py +Index: python-numpy-1.14.5-1ubuntu1/doc/source/conf.py =================================================================== ---- python-numpy-1.14.3-2ubuntu1.orig/doc/source/conf.py -+++ python-numpy-1.14.3-2ubuntu1/doc/source/conf.py +--- python-numpy-1.14.5-1ubuntu1.orig/doc/source/conf.py ++++ python-numpy-1.14.5-1ubuntu1/doc/source/conf.py @@ -22,8 +22,7 @@ extensions = ['sphinx.ext.autodoc', 'numpydoc', 'sphinx.ext.intersphinx', 'sphinx.ext.coverage', diff -Nru python-numpy-1.14.3/debian/patches/fix-alignment-in-void-dtype-setup.patch python-numpy-1.14.5/debian/patches/fix-alignment-in-void-dtype-setup.patch --- python-numpy-1.14.3/debian/patches/fix-alignment-in-void-dtype-setup.patch 2018-05-29 00:17:27.000000000 +0000 +++ python-numpy-1.14.5/debian/patches/fix-alignment-in-void-dtype-setup.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,100 +0,0 @@ -Description: void dtype setup checked offset not actual pointer for alignment -Forwarded: https://github.com/numpy/numpy/pull/11180 -Bug: https://github.com/numpy/numpy/issues/11088 -Author: Sebastian Berg -Last-Update: 2018-05-29 - ---- a/numpy/core/src/multiarray/arraytypes.c.src -+++ b/numpy/core/src/multiarray/arraytypes.c.src -@@ -181,6 +181,15 @@ - ***************************************************************************** - */ - -+#define _ALIGN(type) offsetof(struct {char c; type v;}, v) -+/* -+ * Disable harmless compiler warning "4116: unnamed type definition in -+ * parentheses" which is caused by the _ALIGN macro. -+ */ -+#if defined(_MSC_VER) -+#pragma warning(disable:4116) -+#endif -+ - - /**begin repeat - * -@@ -245,8 +254,10 @@ - } - return -1; - } -- if (ap == NULL || PyArray_ISBEHAVED(ap)) -+ if (ap == NULL || PyArray_ISBEHAVED(ap)) { -+ assert(npy_is_aligned(ov, _ALIGN(@type@))); - *((@type@ *)ov)=temp; -+ } - else { - PyArray_DESCR(ap)->f->copyswap(ov, &temp, PyArray_ISBYTESWAPPED(ap), - ap); -@@ -808,7 +819,7 @@ - */ - NPY_NO_EXPORT int - _setup_field(int i, PyArray_Descr *descr, PyArrayObject *arr, -- npy_intp *offset_p) -+ npy_intp *offset_p, char *dstdata) - { - PyObject *key; - PyObject *tup; -@@ -822,7 +833,8 @@ - } - - ((PyArrayObject_fields *)(arr))->descr = new; -- if ((new->alignment > 1) && ((offset % new->alignment) != 0)) { -+ if ((new->alignment > 1) && -+ ((((uintptr_t)dstdata + offset) % new->alignment) != 0)) { - PyArray_CLEARFLAGS(arr, NPY_ARRAY_ALIGNED); - } - else { -@@ -850,7 +862,7 @@ - if (PyArray_EquivTypes(srcdescr, dstdescr)) { - for (i = 0; i < names_size; i++) { - /* neither line can ever fail, in principle */ -- if (_setup_field(i, dstdescr, dummy, &offset)) { -+ if (_setup_field(i, dstdescr, dummy, &offset, dstdata)) { - return -1; - } - PyArray_DESCR(dummy)->f->copyswap(dstdata + offset, -@@ -920,7 +932,7 @@ - PyObject *item; - - /* temporarily make ap have only this field */ -- if (_setup_field(i, descr, ap, &offset) == -1) { -+ if (_setup_field(i, descr, ap, &offset, ip) == -1) { - failed = 1; - break; - } -@@ -942,7 +954,7 @@ - - for (i = 0; i < names_size; i++) { - /* temporarily make ap have only this field */ -- if (_setup_field(i, descr, ap, &offset) == -1) { -+ if (_setup_field(i, descr, ap, &offset, ip) == -1) { - failed = 1; - break; - } -@@ -4240,17 +4252,6 @@ - ***************************************************************************** - */ - -- --#define _ALIGN(type) offsetof(struct {char c; type v;}, v) --/* -- * Disable harmless compiler warning "4116: unnamed type definition in -- * parentheses" which is caused by the _ALIGN macro. -- */ --#if defined(_MSC_VER) --#pragma warning(disable:4116) --#endif -- -- - /**begin repeat - * - * #from = VOID, STRING, UNICODE# diff -Nru python-numpy-1.14.3/debian/patches/series python-numpy-1.14.5/debian/patches/series --- python-numpy-1.14.3/debian/patches/series 2018-05-29 00:13:48.000000000 +0000 +++ python-numpy-1.14.5/debian/patches/series 2018-06-13 13:01:53.000000000 +0000 @@ -6,4 +6,3 @@ 0006-disable-asserts-on-ppc-with-broken-malloc-only-longd.patch 0007-ENH-Add-support-for-the-64-bit-RISC-V-architecture.patch 20_disable-plot-extension.patch -fix-alignment-in-void-dtype-setup.patch diff -Nru python-numpy-1.14.3/doc/release/1.14.4-notes.rst python-numpy-1.14.5/doc/release/1.14.4-notes.rst --- python-numpy-1.14.3/doc/release/1.14.4-notes.rst 1970-01-01 00:00:00.000000000 +0000 +++ python-numpy-1.14.5/doc/release/1.14.4-notes.rst 2018-06-12 18:28:52.000000000 +0000 @@ -0,0 +1,60 @@ +========================== +NumPy 1.14.4 Release Notes +========================== + +This is a bugfix release for bugs reported following the 1.14.3 release. The +most significant fixes are: + +* fixes for compiler instruction reordering that resulted in NaN's not being + properly propagated in `np.max` and `np.min`, + +* fixes for bus faults on SPARC and older ARM due to incorrect alignment + checks. + +There are also improvements to printing of long doubles on PPC platforms. All +is not yet perfect on that platform, the whitespace padding is still incorrect +and is to be fixed in numpy 1.15, consequently NumPy still fails some +printing-related (and other) unit tests on ppc systems. However, the printed +values are now correct. + +Note that NumPy will error on import if it detects incorrect float32 `dot` +results. This problem has been seen on the Mac when working in the Anaconda +enviroment and is due to a subtle interaction between MKL and PyQt5. It is not +strictly a NumPy problem, but it is best that users be aware of it. See the +gh-8577 NumPy issue for more information. + +The Python versions supported in this release are 2.7 and 3.4 - 3.6. The Python +3.6 wheels available from PIP are built with Python 3.6.2 and should be +compatible with all previous versions of Python 3.6. The source releases were +cythonized with Cython 0.28.2 and should work for the upcoming Python 3.7. + +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 +* Marten van Kerkwijk +* Matti Picus +* Pauli Virtanen +* Ryan Soklaski + +* Sebastian Berg + +Pull requests merged +==================== + +A total of 11 pull requests were merged for this release. + +* `#11104 `__: BUG: str of DOUBLE_DOUBLE format wrong on ppc64 +* `#11170 `__: TST: linalg: add regression test for gh-8577 +* `#11174 `__: MAINT: add sanity-checks to be run at import time +* `#11181 `__: BUG: void dtype setup checked offset not actual pointer for alignment +* `#11194 `__: BUG: Python2 doubles don't print correctly in interactive shell. +* `#11198 `__: BUG: optimizing compilers can reorder call to npy_get_floatstatus +* `#11199 `__: BUG: reduce using SSE only warns if inside SSE loop +* `#11203 `__: BUG: Bytes delimiter/comments in genfromtxt should be decoded +* `#11211 `__: BUG: Fix reference count/memory leak exposed by better testing +* `#11219 `__: BUG: Fixes einsum broadcasting bug when optimize=True +* `#11251 `__: DOC: Document 1.14.4 release. diff -Nru python-numpy-1.14.3/doc/release/1.14.5-notes.rst python-numpy-1.14.5/doc/release/1.14.5-notes.rst --- python-numpy-1.14.3/doc/release/1.14.5-notes.rst 1970-01-01 00:00:00.000000000 +0000 +++ python-numpy-1.14.5/doc/release/1.14.5-notes.rst 2018-06-12 18:28:52.000000000 +0000 @@ -0,0 +1,30 @@ +========================== +NumPy 1.14.5 Release Notes +========================== + +This is a bugfix release for bugs reported following the 1.14.4 release. The +most significant fixes are: + +* fixes for compilation errors on alpine and NetBSD + +The Python versions supported in this release are 2.7 and 3.4 - 3.6. The Python +3.6 wheels available from PIP are built with Python 3.6.2 and should be +compatible with all previous versions of Python 3.6. The source releases were +cythonized with Cython 0.28.2 and should work for the upcoming Python 3.7. + +Contributors +============ + +A total of 1 person contributed to this release. People with a "+" by their +names contributed a patch for the first time. + +* Charles Harris + +Pull requests merged +==================== + +A total of 2 pull requests were merged for this release. + +* `#11274 `__: BUG: Correct use of NPY_UNUSED. +* `#11294 `__: BUG: Remove extra trailing parentheses. + diff -Nru python-numpy-1.14.3/doc/source/reference/c-api.coremath.rst python-numpy-1.14.5/doc/source/reference/c-api.coremath.rst --- python-numpy-1.14.3/doc/source/reference/c-api.coremath.rst 2018-04-25 21:12:00.000000000 +0000 +++ python-numpy-1.14.5/doc/source/reference/c-api.coremath.rst 2018-06-12 17:31:56.000000000 +0000 @@ -183,14 +183,46 @@ * NPY_FPE_UNDERFLOW * NPY_FPE_INVALID + Note that :c:func:`npy_get_floatstatus_barrier` is preferable as it prevents + agressive compiler optimizations reordering the call relative to + the code setting the status, which could lead to incorrect results. + .. versionadded:: 1.9.0 +.. c:function:: int npy_get_floatstatus_barrier(char*) + + Get floating point status. A pointer to a local variable is passed in to + prevent aggresive compiler optimizations from reodering this function call + relative to the code setting the status, which could lead to incorrect + results. + + Returns a bitmask with following possible flags: + + * NPY_FPE_DIVIDEBYZERO + * NPY_FPE_OVERFLOW + * NPY_FPE_UNDERFLOW + * NPY_FPE_INVALID + + .. versionadded:: 1.15.0 + .. c:function:: int npy_clear_floatstatus() Clears the floating point status. Returns the previous status mask. + Note that :c:func:`npy_clear_floatstatus_barrier` is preferable as it + prevents agressive compiler optimizations reordering the call relative to + the code setting the status, which could lead to incorrect results. + .. versionadded:: 1.9.0 +.. c:function:: int npy_clear_floatstatus_barrier(char*) + + Clears the floating point status. A pointer to a local variable is passed in to + prevent aggresive compiler optimizations from reodering this function call. + Returns the previous status mask. + + .. versionadded:: 1.15.0 +n Complex functions ~~~~~~~~~~~~~~~~~ @@ -237,7 +269,7 @@ Like for other types, NumPy includes a typedef npy_half for the 16 bit float. Unlike for most of the other types, you cannot use this as a -normal type in C, since is is a typedef for npy_uint16. For example, +normal type in C, since it is a typedef for npy_uint16. For example, 1.0 looks like 0x3c00 to C, and if you do an equality comparison between the different signed zeros, you will get -0.0 != 0.0 (0x8000 != 0x0000), which is incorrect. diff -Nru python-numpy-1.14.3/doc/source/release.rst python-numpy-1.14.5/doc/source/release.rst --- python-numpy-1.14.3/doc/source/release.rst 2018-04-25 21:12:00.000000000 +0000 +++ python-numpy-1.14.5/doc/source/release.rst 2018-06-12 18:28:52.000000000 +0000 @@ -2,6 +2,9 @@ Release Notes ************* +.. include:: ../release/1.14.5-notes.rst +.. include:: ../release/1.14.4-notes.rst +.. include:: ../release/1.14.3-notes.rst .. include:: ../release/1.14.2-notes.rst .. include:: ../release/1.14.1-notes.rst .. include:: ../release/1.14.0-notes.rst diff -Nru python-numpy-1.14.3/numpy/core/einsumfunc.py python-numpy-1.14.5/numpy/core/einsumfunc.py --- python-numpy-1.14.3/numpy/core/einsumfunc.py 2018-04-25 21:12:00.000000000 +0000 +++ python-numpy-1.14.5/numpy/core/einsumfunc.py 2018-06-12 18:28:52.000000000 +0000 @@ -1109,7 +1109,7 @@ # Checks have already been handled input_str, results_index = einsum_str.split('->') input_left, input_right = input_str.split(',') - if 1 in tmp_operands[0] or 1 in tmp_operands[1]: + if 1 in tmp_operands[0].shape or 1 in tmp_operands[1].shape: left_dims = {dim: size for dim, size in zip(input_left, tmp_operands[0].shape)} right_dims = {dim: size for dim, size in diff -Nru python-numpy-1.14.3/numpy/core/include/numpy/npy_math.h python-numpy-1.14.5/numpy/core/include/numpy/npy_math.h --- python-numpy-1.14.3/numpy/core/include/numpy/npy_math.h 2018-04-23 22:28:56.000000000 +0000 +++ python-numpy-1.14.5/numpy/core/include/numpy/npy_math.h 2018-06-12 18:28:52.000000000 +0000 @@ -524,8 +524,14 @@ #define NPY_FPE_UNDERFLOW 4 #define NPY_FPE_INVALID 8 -int npy_get_floatstatus(void); +int npy_clear_floatstatus_barrier(char*); +int npy_get_floatstatus_barrier(char*); +/* + * use caution with these - clang and gcc8.1 are known to reorder calls + * to this form of the function which can defeat the check + */ int npy_clear_floatstatus(void); +int npy_get_floatstatus(void); void npy_set_floatstatus_divbyzero(void); void npy_set_floatstatus_overflow(void); void npy_set_floatstatus_underflow(void); diff -Nru python-numpy-1.14.3/numpy/core/src/multiarray/arraytypes.c.src python-numpy-1.14.5/numpy/core/src/multiarray/arraytypes.c.src --- python-numpy-1.14.3/numpy/core/src/multiarray/arraytypes.c.src 2018-04-25 21:12:00.000000000 +0000 +++ python-numpy-1.14.5/numpy/core/src/multiarray/arraytypes.c.src 2018-06-12 18:28:52.000000000 +0000 @@ -181,6 +181,15 @@ ***************************************************************************** */ +#define _ALIGN(type) offsetof(struct {char c; type v;}, v) +/* + * Disable harmless compiler warning "4116: unnamed type definition in + * parentheses" which is caused by the _ALIGN macro. + */ +#if defined(_MSC_VER) +#pragma warning(disable:4116) +#endif + /**begin repeat * @@ -245,8 +254,10 @@ } return -1; } - if (ap == NULL || PyArray_ISBEHAVED(ap)) + if (ap == NULL || PyArray_ISBEHAVED(ap)) { + assert(npy_is_aligned(ov, _ALIGN(@type@))); *((@type@ *)ov)=temp; + } else { PyArray_DESCR(ap)->f->copyswap(ov, &temp, PyArray_ISBYTESWAPPED(ap), ap); @@ -808,7 +819,7 @@ */ NPY_NO_EXPORT int _setup_field(int i, PyArray_Descr *descr, PyArrayObject *arr, - npy_intp *offset_p) + npy_intp *offset_p, char *dstdata) { PyObject *key; PyObject *tup; @@ -822,7 +833,8 @@ } ((PyArrayObject_fields *)(arr))->descr = new; - if ((new->alignment > 1) && ((offset % new->alignment) != 0)) { + if ((new->alignment > 1) && + ((((uintptr_t)dstdata + offset) % new->alignment) != 0)) { PyArray_CLEARFLAGS(arr, NPY_ARRAY_ALIGNED); } else { @@ -850,7 +862,7 @@ if (PyArray_EquivTypes(srcdescr, dstdescr)) { for (i = 0; i < names_size; i++) { /* neither line can ever fail, in principle */ - if (_setup_field(i, dstdescr, dummy, &offset)) { + if (_setup_field(i, dstdescr, dummy, &offset, dstdata)) { return -1; } PyArray_DESCR(dummy)->f->copyswap(dstdata + offset, @@ -920,7 +932,7 @@ PyObject *item; /* temporarily make ap have only this field */ - if (_setup_field(i, descr, ap, &offset) == -1) { + if (_setup_field(i, descr, ap, &offset, ip) == -1) { failed = 1; break; } @@ -942,7 +954,7 @@ for (i = 0; i < names_size; i++) { /* temporarily make ap have only this field */ - if (_setup_field(i, descr, ap, &offset) == -1) { + if (_setup_field(i, descr, ap, &offset, ip) == -1) { failed = 1; break; } @@ -4240,17 +4252,6 @@ ***************************************************************************** */ - -#define _ALIGN(type) offsetof(struct {char c; type v;}, v) -/* - * Disable harmless compiler warning "4116: unnamed type definition in - * parentheses" which is caused by the _ALIGN macro. - */ -#if defined(_MSC_VER) -#pragma warning(disable:4116) -#endif - - /**begin repeat * * #from = VOID, STRING, UNICODE# diff -Nru python-numpy-1.14.3/numpy/core/src/multiarray/dragon4.c python-numpy-1.14.5/numpy/core/src/multiarray/dragon4.c --- python-numpy-1.14.3/numpy/core/src/multiarray/dragon4.c 2018-04-23 22:28:56.000000000 +0000 +++ python-numpy-1.14.5/numpy/core/src/multiarray/dragon4.c 2018-06-12 18:28:52.000000000 +0000 @@ -2404,6 +2404,8 @@ } } +#if !(defined(HAVE_LDOUBLE_DOUBLE_DOUBLE_BE) || \ + defined(HAVE_LDOUBLE_DOUBLE_DOUBLE_LE)) static npy_uint32 Dragon4_PrintFloat128(char *buffer, npy_uint32 bufferSize, FloatVal128 value, npy_bool scientific, DigitMode digit_mode, @@ -2499,6 +2501,7 @@ digits_left, digits_right); } } +#endif /* DOUBLE_DOUBLE */ PyObject * Dragon4_Positional_AnySize(void *val, size_t size, DigitMode digit_mode, @@ -2510,16 +2513,22 @@ * 16384 should be enough to uniquely print any float128, which goes up * to about 10^4932 */ static char repr[16384]; +#if !(defined(HAVE_LDOUBLE_DOUBLE_DOUBLE_BE) || \ + defined(HAVE_LDOUBLE_DOUBLE_DOUBLE_LE)) FloatVal128 val128; +#ifdef NPY_FLOAT128 + FloatUnion128 buf128; +#endif +#else /* DOUBLE_DOUBLE */ + PyObject *out, *ret; +#endif /* DOUBLE_DOUBLE */ + #ifdef NPY_FLOAT80 FloatUnion80 buf80;; #endif #ifdef NPY_FLOAT96 FloatUnion96 buf96; #endif -#ifdef NPY_FLOAT128 - FloatUnion128 buf128; -#endif switch (size) { case 2: @@ -2559,14 +2568,29 @@ #endif #ifdef NPY_FLOAT128 case 16: +/* Numpy 1.14 does not support the DOUBLE_DOUBLE format properly */ +#if defined(HAVE_LDOUBLE_DOUBLE_DOUBLE_BE) || \ + defined(HAVE_LDOUBLE_DOUBLE_DOUBLE_LE) + PyOS_snprintf(repr, sizeof(repr), "%.*Lf", precision, + *(npy_float128*)val); + out = PyUString_FromString(repr); + if (out == NULL) { + return out; + } + /* strip trailing zeros to roughly emulate normal behavior */ + ret = PyObject_CallMethod(out, "rstrip", "s", "0"); + Py_DECREF(out); + return ret; +#else buf128.floatingPoint = *(npy_float128*)val; val128.integer[0] = buf128.integer.a; val128.integer[1] = buf128.integer.b; Dragon4_PrintFloat128(repr, sizeof(repr), val128, 0, digit_mode, cutoff_mode, precision, sign, trim, pad_left, pad_right, -1); +#endif /* DOUBLE_DOUBLE */ break; -#endif +#endif /* NPY_FLOAT128 */ default: PyErr_Format(PyExc_ValueError, "unexpected itemsize %zu", size); return NULL; @@ -2623,16 +2647,20 @@ { /* use a very large buffer in case anyone tries to output a large precision */ static char repr[4096]; +#if !(defined(HAVE_LDOUBLE_DOUBLE_DOUBLE_BE) || \ + defined(HAVE_LDOUBLE_DOUBLE_DOUBLE_LE)) FloatVal128 val128; +#ifdef NPY_FLOAT128 + FloatUnion128 buf128; +#endif +#endif /* DOUBLE_DOUBLE */ + #ifdef NPY_FLOAT80 FloatUnion80 buf80;; #endif #ifdef NPY_FLOAT96 FloatUnion96 buf96; #endif -#ifdef NPY_FLOAT128 - FloatUnion128 buf128; -#endif /* dummy, is ignored in scientific mode */ CutoffMode cutoff_mode = CutoffMode_TotalLength; @@ -2675,14 +2703,21 @@ #endif #ifdef NPY_FLOAT128 case 16: +/* Numpy 1.14 does not support the DOUBLE_DOUBLE format properly */ +#if defined(HAVE_LDOUBLE_DOUBLE_DOUBLE_BE) || \ + defined(HAVE_LDOUBLE_DOUBLE_DOUBLE_LE) + PyOS_snprintf(repr, sizeof(repr), "%.*Le", precision, + *(npy_float128*)val); +#else buf128.floatingPoint = *(npy_float128*)val; val128.integer[0] = buf128.integer.a; val128.integer[1] = buf128.integer.b; Dragon4_PrintFloat128(repr, sizeof(repr), val128, 1, digit_mode, cutoff_mode, precision, sign, trim, pad_left, -1, exp_digits); +#endif /* DOUBLE_DOUBLE */ break; -#endif +#endif /* NPY_FLOAT128 */ default: PyErr_Format(PyExc_ValueError, "unexpected itemsize %zu", size); return NULL; diff -Nru python-numpy-1.14.3/numpy/core/src/multiarray/scalartypes.c.src python-numpy-1.14.5/numpy/core/src/multiarray/scalartypes.c.src --- python-numpy-1.14.3/numpy/core/src/multiarray/scalartypes.c.src 2018-04-27 20:14:44.000000000 +0000 +++ python-numpy-1.14.5/numpy/core/src/multiarray/scalartypes.c.src 2018-06-12 18:28:52.000000000 +0000 @@ -4205,7 +4205,7 @@ return -1; } - ret = PyObject_Print(to_print, fp, flags); + ret = PyObject_Print(to_print, fp, Py_PRINT_RAW); Py_DECREF(to_print); return ret; } diff -Nru python-numpy-1.14.3/numpy/core/src/npymath/ieee754.c.src python-numpy-1.14.5/numpy/core/src/npymath/ieee754.c.src --- python-numpy-1.14.3/numpy/core/src/npymath/ieee754.c.src 2018-04-25 21:12:00.000000000 +0000 +++ python-numpy-1.14.5/numpy/core/src/npymath/ieee754.c.src 2018-06-12 18:28:52.000000000 +0000 @@ -6,6 +6,7 @@ */ #include "npy_math_common.h" #include "npy_math_private.h" +#include "numpy/utils.h" #ifndef HAVE_COPYSIGN double npy_copysign(double x, double y) @@ -557,6 +558,15 @@ } #endif +int npy_clear_floatstatus() { + char x=0; + return npy_clear_floatstatus_barrier(&x); +} +int npy_get_floatstatus() { + char x=0; + return npy_get_floatstatus_barrier(&x); +} + /* * Functions to set the floating point status word. * keep in sync with NO_FLOATING_POINT_SUPPORT in ufuncobject.h @@ -574,18 +584,24 @@ defined(__NetBSD__) #include -int npy_get_floatstatus(void) +int npy_get_floatstatus_barrier(char * param) { int fpstatus = fpgetsticky(); + /* + * By using a volatile, the compiler cannot reorder this call + */ + if (param != NULL) { + volatile char NPY_UNUSED(c) = *(char*)param; + } return ((FP_X_DZ & fpstatus) ? NPY_FPE_DIVIDEBYZERO : 0) | ((FP_X_OFL & fpstatus) ? NPY_FPE_OVERFLOW : 0) | ((FP_X_UFL & fpstatus) ? NPY_FPE_UNDERFLOW : 0) | ((FP_X_INV & fpstatus) ? NPY_FPE_INVALID : 0); } -int npy_clear_floatstatus(void) +int npy_clear_floatstatus_barrier(char * param) { - int fpstatus = npy_get_floatstatus(); + int fpstatus = npy_get_floatstatus_barrier(param); fpsetsticky(0); return fpstatus; @@ -617,10 +633,16 @@ (defined(__FreeBSD__) && (__FreeBSD_version >= 502114)) # include -int npy_get_floatstatus(void) +int npy_get_floatstatus_barrier(char* param) { int fpstatus = fetestexcept(FE_DIVBYZERO | FE_OVERFLOW | FE_UNDERFLOW | FE_INVALID); + /* + * By using a volatile, the compiler cannot reorder this call + */ + if (param != NULL) { + volatile char NPY_UNUSED(c) = *(char*)param; + } return ((FE_DIVBYZERO & fpstatus) ? NPY_FPE_DIVIDEBYZERO : 0) | ((FE_OVERFLOW & fpstatus) ? NPY_FPE_OVERFLOW : 0) | @@ -628,10 +650,10 @@ ((FE_INVALID & fpstatus) ? NPY_FPE_INVALID : 0); } -int npy_clear_floatstatus(void) +int npy_clear_floatstatus_barrier(char * param) { /* testing float status is 50-100 times faster than clearing on x86 */ - int fpstatus = npy_get_floatstatus(); + int fpstatus = npy_get_floatstatus_barrier(param); if (fpstatus != 0) { feclearexcept(FE_DIVBYZERO | FE_OVERFLOW | FE_UNDERFLOW | FE_INVALID); @@ -665,18 +687,24 @@ #include #include -int npy_get_floatstatus(void) +int npy_get_floatstatus_barrier(char *param) { int fpstatus = fp_read_flag(); + /* + * By using a volatile, the compiler cannot reorder this call + */ + if (param != NULL) { + volatile char NPY_UNUSED(c) = *(char*)param; + } return ((FP_DIV_BY_ZERO & fpstatus) ? NPY_FPE_DIVIDEBYZERO : 0) | ((FP_OVERFLOW & fpstatus) ? NPY_FPE_OVERFLOW : 0) | ((FP_UNDERFLOW & fpstatus) ? NPY_FPE_UNDERFLOW : 0) | ((FP_INVALID & fpstatus) ? NPY_FPE_INVALID : 0); } -int npy_clear_floatstatus(void) +int npy_clear_floatstatus_barrier(char * param) { - int fpstatus = npy_get_floatstatus(); + int fpstatus = npy_get_floatstatus_barrier(param); fp_swap_flag(0); return fpstatus; @@ -710,8 +738,11 @@ #include -int npy_get_floatstatus(void) +int npy_get_floatstatus_barrier(char *param) { + /* + * By using a volatile, the compiler cannot reorder this call + */ #if defined(_WIN64) int fpstatus = _statusfp(); #else @@ -720,15 +751,18 @@ _statusfp2(&fpstatus, &fpstatus2); fpstatus |= fpstatus2; #endif + if (param != NULL) { + volatile char NPY_UNUSED(c) = *(char*)param; + } return ((SW_ZERODIVIDE & fpstatus) ? NPY_FPE_DIVIDEBYZERO : 0) | ((SW_OVERFLOW & fpstatus) ? NPY_FPE_OVERFLOW : 0) | ((SW_UNDERFLOW & fpstatus) ? NPY_FPE_UNDERFLOW : 0) | ((SW_INVALID & fpstatus) ? NPY_FPE_INVALID : 0); } -int npy_clear_floatstatus(void) +int npy_clear_floatstatus_barrier(char *param) { - int fpstatus = npy_get_floatstatus(); + int fpstatus = npy_get_floatstatus_barrier(param); _clearfp(); return fpstatus; @@ -739,18 +773,24 @@ #include -int npy_get_floatstatus(void) +int npy_get_floatstatus_barrier(char *param) { unsigned long fpstatus = ieee_get_fp_control(); + /* + * By using a volatile, the compiler cannot reorder this call + */ + if (param != NULL) { + volatile char NPY_UNUSED(c) = *(char*)param; + } return ((IEEE_STATUS_DZE & fpstatus) ? NPY_FPE_DIVIDEBYZERO : 0) | ((IEEE_STATUS_OVF & fpstatus) ? NPY_FPE_OVERFLOW : 0) | ((IEEE_STATUS_UNF & fpstatus) ? NPY_FPE_UNDERFLOW : 0) | ((IEEE_STATUS_INV & fpstatus) ? NPY_FPE_INVALID : 0); } -int npy_clear_floatstatus(void) +int npy_clear_floatstatus_barrier(char *param) { - long fpstatus = npy_get_floatstatus(); + int fpstatus = npy_get_floatstatus_barrier(param); /* clear status bits as well as disable exception mode if on */ ieee_set_fp_control(0); @@ -759,13 +799,14 @@ #else -int npy_get_floatstatus(void) +int npy_get_floatstatus_barrier(char *NPY_UNUSED(param)) { return 0; } -int npy_clear_floatstatus(void) +int npy_clear_floatstatus_barrier(char *param) { + int fpstatus = npy_get_floatstatus_barrier(param); return 0; } diff -Nru python-numpy-1.14.3/numpy/core/src/umath/extobj.c python-numpy-1.14.5/numpy/core/src/umath/extobj.c --- python-numpy-1.14.3/numpy/core/src/umath/extobj.c 2018-04-23 22:28:56.000000000 +0000 +++ python-numpy-1.14.5/numpy/core/src/umath/extobj.c 2018-06-12 17:31:56.000000000 +0000 @@ -284,7 +284,7 @@ if (!errmask) { return 0; } - fperr = PyUFunc_getfperr(); + fperr = npy_get_floatstatus_barrier((char*)extobj); if (!fperr) { return 0; } diff -Nru python-numpy-1.14.3/numpy/core/src/umath/loops.c.src python-numpy-1.14.5/numpy/core/src/umath/loops.c.src --- python-numpy-1.14.3/numpy/core/src/umath/loops.c.src 2018-04-25 21:12:00.000000000 +0000 +++ python-numpy-1.14.5/numpy/core/src/umath/loops.c.src 2018-06-12 18:28:52.000000000 +0000 @@ -1775,7 +1775,7 @@ *((npy_bool *)op1) = @func@(in1) != 0; } } - npy_clear_floatstatus(); + npy_clear_floatstatus_barrier((char*)dimensions); } /**end repeat1**/ @@ -1822,6 +1822,9 @@ const @type@ in2 = *(@type@ *)ip2; io1 = (io1 @OP@ in2 || npy_isnan(io1)) ? io1 : in2; } + if (npy_isnan(io1)) { + npy_set_floatstatus_invalid(); + } *((@type@ *)iop1) = io1; } } @@ -1857,7 +1860,7 @@ *((@type@ *)op1) = (in1 @OP@ in2 || npy_isnan(in2)) ? in1 : in2; } } - npy_clear_floatstatus(); + npy_clear_floatstatus_barrier((char*)dimensions); } /**end repeat1**/ @@ -1947,7 +1950,7 @@ *((@type@ *)op1) = tmp + 0; } } - npy_clear_floatstatus(); + npy_clear_floatstatus_barrier((char*)dimensions); } NPY_NO_EXPORT void @@ -2133,7 +2136,7 @@ const npy_half in1 = *(npy_half *)ip1; *((npy_bool *)op1) = @func@(in1) != 0; } - npy_clear_floatstatus(); + npy_clear_floatstatus_barrier((char*)dimensions); } /**end repeat**/ @@ -2195,7 +2198,7 @@ const npy_half in2 = *(npy_half *)ip2; *((npy_half *)op1) = (@OP@(in1, in2) || npy_half_isnan(in2)) ? in1 : in2; } - npy_clear_floatstatus(); + npy_clear_floatstatus_barrier((char*)dimensions); } /**end repeat**/ @@ -2635,7 +2638,7 @@ const @ftype@ in1i = ((@ftype@ *)ip1)[1]; *((npy_bool *)op1) = @func@(in1r) @OP@ @func@(in1i); } - npy_clear_floatstatus(); + npy_clear_floatstatus_barrier((char*)dimensions); } /**end repeat1**/ @@ -2744,7 +2747,7 @@ ((@ftype@ *)op1)[1] = in2i; } } - npy_clear_floatstatus(); + npy_clear_floatstatus_barrier((char*)dimensions); } /**end repeat1**/ diff -Nru python-numpy-1.14.3/numpy/core/src/umath/override.c python-numpy-1.14.5/numpy/core/src/umath/override.c --- python-numpy-1.14.3/numpy/core/src/umath/override.c 2018-04-25 21:12:00.000000000 +0000 +++ python-numpy-1.14.5/numpy/core/src/umath/override.c 2018-06-12 18:28:52.000000000 +0000 @@ -29,7 +29,10 @@ "cannot specify both 'sig' and 'signature'"); return -1; } - Py_INCREF(obj); + /* + * No INCREF or DECREF needed: got a borrowed reference above, + * and, unlike e.g. PyList_SetItem, PyDict_SetItem INCREF's it. + */ PyDict_SetItemString(normal_kwds, "signature", obj); PyDict_DelItemString(normal_kwds, "sig"); } @@ -282,7 +285,6 @@ if (*normal_args == NULL) { return -1; } - /* ufuncs accept 'sig' or 'signature' normalize to 'signature' */ return normalize_signature_keyword(*normal_kwds); } diff -Nru python-numpy-1.14.3/numpy/core/src/umath/reduction.c python-numpy-1.14.5/numpy/core/src/umath/reduction.c --- python-numpy-1.14.3/numpy/core/src/umath/reduction.c 2018-04-25 21:12:00.000000000 +0000 +++ python-numpy-1.14.5/numpy/core/src/umath/reduction.c 2018-06-12 18:28:52.000000000 +0000 @@ -560,7 +560,7 @@ } /* Start with the floating-point exception flags cleared */ - PyUFunc_clearfperr(); + npy_clear_floatstatus_barrier((char*)&iter); if (NpyIter_GetIterSize(iter) != 0) { NpyIter_IterNextFunc *iternext; diff -Nru python-numpy-1.14.3/numpy/core/src/umath/scalarmath.c.src python-numpy-1.14.5/numpy/core/src/umath/scalarmath.c.src --- python-numpy-1.14.3/numpy/core/src/umath/scalarmath.c.src 2018-04-25 21:12:00.000000000 +0000 +++ python-numpy-1.14.5/numpy/core/src/umath/scalarmath.c.src 2018-06-12 18:28:52.000000000 +0000 @@ -854,7 +854,7 @@ } #if @fperr@ - PyUFunc_clearfperr(); + npy_clear_floatstatus_barrier((char*)&out); #endif /* @@ -869,7 +869,7 @@ #if @fperr@ /* Check status flag. If it is set, then look up what to do */ - retstatus = PyUFunc_getfperr(); + retstatus = npy_get_floatstatus_barrier((char*)&out); if (retstatus) { int bufsize, errmask; PyObject *errobj; @@ -999,7 +999,7 @@ return Py_NotImplemented; } - PyUFunc_clearfperr(); + npy_clear_floatstatus_barrier((char*)&out); /* * here we do the actual calculation with arg1 and arg2 @@ -1014,7 +1014,7 @@ } /* Check status flag. If it is set, then look up what to do */ - retstatus = PyUFunc_getfperr(); + retstatus = npy_get_floatstatus_barrier((char*)&out); if (retstatus) { int bufsize, errmask; PyObject *errobj; @@ -1078,7 +1078,7 @@ return Py_NotImplemented; } - PyUFunc_clearfperr(); + npy_clear_floatstatus_barrier((char*)&out); /* * here we do the actual calculation with arg1 and arg2 @@ -1142,7 +1142,7 @@ return Py_NotImplemented; } - PyUFunc_clearfperr(); + npy_clear_floatstatus_barrier((char*)&out); /* * here we do the actual calculation with arg1 and arg2 @@ -1156,7 +1156,7 @@ } /* Check status flag. If it is set, then look up what to do */ - retstatus = PyUFunc_getfperr(); + retstatus = npy_get_floatstatus_barrier((char*)&out); if (retstatus) { int bufsize, errmask; PyObject *errobj; diff -Nru python-numpy-1.14.3/numpy/core/src/umath/simd.inc.src python-numpy-1.14.5/numpy/core/src/umath/simd.inc.src --- python-numpy-1.14.3/numpy/core/src/umath/simd.inc.src 2018-04-25 21:12:00.000000000 +0000 +++ python-numpy-1.14.5/numpy/core/src/umath/simd.inc.src 2018-06-12 18:28:52.000000000 +0000 @@ -840,7 +840,7 @@ i += 2 * stride; /* minps/minpd will set invalid flag if nan is encountered */ - npy_clear_floatstatus(); + npy_clear_floatstatus_barrier((char*)&c1); LOOP_BLOCKED(@type@, 32) { @vtype@ v1 = @vpre@_load_@vsuf@((@type@*)&ip[i]); @vtype@ v2 = @vpre@_load_@vsuf@((@type@*)&ip[i + stride]); @@ -849,7 +849,7 @@ } c1 = @vpre@_@VOP@_@vsuf@(c1, c2); - if (npy_get_floatstatus() & NPY_FPE_INVALID) { + if (npy_get_floatstatus_barrier((char*)&c1) & NPY_FPE_INVALID) { *op = @nan@; } else { @@ -860,6 +860,9 @@ LOOP_BLOCKED_END { *op = (*op @OP@ ip[i] || npy_isnan(*op)) ? *op : ip[i]; } + if (npy_isnan(*op)) { + npy_set_floatstatus_invalid(); + } } /**end repeat1**/ diff -Nru python-numpy-1.14.3/numpy/core/src/umath/ufunc_object.c python-numpy-1.14.5/numpy/core/src/umath/ufunc_object.c --- python-numpy-1.14.3/numpy/core/src/umath/ufunc_object.c 2018-04-25 21:12:00.000000000 +0000 +++ python-numpy-1.14.5/numpy/core/src/umath/ufunc_object.c 2018-06-12 18:28:52.000000000 +0000 @@ -88,7 +88,8 @@ * non-clearing get was only added in 1.9 so this function always cleared * keep it so just in case third party code relied on the clearing */ - return npy_clear_floatstatus(); + char param = 0; + return npy_clear_floatstatus_barrier(¶m); } #define HANDLEIT(NAME, str) {if (retstatus & NPY_FPE_##NAME) { \ @@ -121,7 +122,8 @@ PyUFunc_checkfperr(int errmask, PyObject *errobj, int *first) { /* clearing is done for backward compatibility */ - int retstatus = npy_clear_floatstatus(); + int retstatus; + retstatus = npy_clear_floatstatus_barrier((char*)&retstatus); return PyUFunc_handlefperr(errmask, errobj, retstatus, first); } @@ -132,7 +134,8 @@ NPY_NO_EXPORT void PyUFunc_clearfperr() { - npy_clear_floatstatus(); + char param = 0; + npy_clear_floatstatus_barrier(¶m); } /* @@ -2229,7 +2232,7 @@ #endif /* Start with the floating-point exception flags cleared */ - PyUFunc_clearfperr(); + npy_clear_floatstatus_barrier((char*)&iter); NPY_UF_DBG_PRINT("Executing inner loop\n"); @@ -2479,7 +2482,7 @@ } /* Start with the floating-point exception flags cleared */ - PyUFunc_clearfperr(); + npy_clear_floatstatus_barrier((char*)&ufunc); /* Do the ufunc loop */ if (need_fancy) { diff -Nru python-numpy-1.14.3/numpy/core/tests/test_einsum.py python-numpy-1.14.5/numpy/core/tests/test_einsum.py --- python-numpy-1.14.3/numpy/core/tests/test_einsum.py 2018-04-25 21:12:00.000000000 +0000 +++ python-numpy-1.14.5/numpy/core/tests/test_einsum.py 2018-06-12 18:28:52.000000000 +0000 @@ -489,8 +489,16 @@ assert_array_equal(np.einsum('ij,ij->j', p, q, optimize=True), [10.] * 2) - p = np.ones((1, 5)) - q = np.ones((5, 5)) + # a blas-compatible contraction broadcasting case which was failing + # for optimize=True (ticket #10930) + x = np.array([2., 3.]) + y = np.array([4.]) + assert_array_equal(np.einsum("i, i", x, y, optimize=False), 20.) + assert_array_equal(np.einsum("i, i", x, y, optimize=True), 20.) + + # all-ones array was bypassing bug (ticket #10930) + p = np.ones((1, 5)) / 2 + q = np.ones((5, 5)) / 2 for optimize in (True, False): assert_array_equal(np.einsum("...ij,...jk->...ik", p, p, optimize=optimize), @@ -498,7 +506,7 @@ optimize=optimize)) assert_array_equal(np.einsum("...ij,...jk->...ik", p, q, optimize=optimize), - np.full((1, 5), 5)) + np.full((1, 5), 1.25)) def test_einsum_sums_int8(self): self.check_einsum_sums('i1') diff -Nru python-numpy-1.14.3/numpy/core/tests/test_scalarprint.py python-numpy-1.14.5/numpy/core/tests/test_scalarprint.py --- python-numpy-1.14.3/numpy/core/tests/test_scalarprint.py 2018-04-27 20:14:44.000000000 +0000 +++ python-numpy-1.14.5/numpy/core/tests/test_scalarprint.py 2018-06-12 18:28:52.000000000 +0000 @@ -4,11 +4,13 @@ """ from __future__ import division, absolute_import, print_function +import code, sys +from tempfile import TemporaryFile import numpy as np -from numpy.testing import assert_, assert_equal, run_module_suite +from numpy.testing import assert_, assert_equal, suppress_warnings,\ + run_module_suite import sys, tempfile - class TestRealScalars(object): def test_str(self): svals = [0.0, -0.0, 1, -1, np.inf, -np.inf, np.nan] @@ -53,13 +55,45 @@ # keyword/method to output to a "real file" (ie, not a StringIO). Make # sure we don't inherit it. x = np.double(0.1999999999999) - f = tempfile.TemporaryFile('r+t') # must output to real file, not StringIO - print(x, file=f) - f.seek(0) - output = f.read() - f.close() - assert_equal(output, '0.1999999999999\n') - # (compare to "print 0.1999999999999" printing "0.2" in python2) + with TemporaryFile('r+t') as f: + print(x, file=f) + f.seek(0) + output = f.read() + assert_equal(output, str(x) + '\n') + # In python2 the value float('0.1999999999999') prints with reduced + # precision as '0.2', but we want numpy's np.double('0.1999999999999') + # to print the unique value, '0.1999999999999'. + + # gh-11031 + # Only in the python2 interactive shell and when stdout is a "real" + # file, the output of the last command is printed to stdout without + # Py_PRINT_RAW (unlike the print statement) so `>>> x` and `>>> print + # x` are potentially different. Make sure they are the same. The only + # way I found to get prompt-like output is using an actual prompt from + # the 'code' module. Again, must use tempfile to get a "real" file. + + # dummy user-input which enters one line and then ctrl-Ds. + def userinput(): + yield 'np.sqrt(2)' + raise EOFError + gen = userinput() + input_func = lambda prompt="": next(gen) + + with TemporaryFile('r+t') as fo, TemporaryFile('r+t') as fe: + orig_stdout, orig_stderr = sys.stdout, sys.stderr + sys.stdout, sys.stderr = fo, fe + + # py2 code.interact sends irrelevant internal DeprecationWarnings + with suppress_warnings() as sup: + sup.filter(DeprecationWarning) + code.interact(local={'np': np}, readfunc=input_func, banner='') + + sys.stdout, sys.stderr = orig_stdout, orig_stderr + + fo.seek(0) + capture = fo.read().strip() + + assert_equal(capture, repr(np.sqrt(2))) def test_dragon4(self): # these tests are adapted from Ryan Juckett's dragon4 implementation, diff -Nru python-numpy-1.14.3/numpy/core/tests/test_umath.py python-numpy-1.14.5/numpy/core/tests/test_umath.py --- python-numpy-1.14.3/numpy/core/tests/test_umath.py 2018-04-25 21:12:00.000000000 +0000 +++ python-numpy-1.14.5/numpy/core/tests/test_umath.py 2018-06-12 18:28:52.000000000 +0000 @@ -1327,6 +1327,17 @@ assert_equal(d.max(), d[0]) assert_equal(d.min(), d[0]) + def test_reduce_warns(self): + # gh 10370, 11029 Some compilers reorder the call to npy_getfloatstatus + # and put it before the call to an intrisic function that causes + # invalid status to be set. Also make sure warnings are emitted + for n in (2, 4, 8, 16, 32): + with suppress_warnings() as sup: + sup.record(RuntimeWarning) + for r in np.diagflat([np.nan] * n): + assert_equal(np.min(r), np.nan) + assert_equal(len(sup.log), n) + class TestAbsoluteNegative(object): def test_abs_neg_blocked(self): @@ -1865,6 +1876,7 @@ # outer, wrong args assert_raises(TypeError, np.multiply.outer, a) assert_raises(TypeError, np.multiply.outer, a, a, a, a) + assert_raises(TypeError, np.multiply.outer, a, a, sig='a', signature='a') # at res = np.multiply.at(a, [4, 2], 'b0') diff -Nru python-numpy-1.14.3/numpy/__init__.py python-numpy-1.14.5/numpy/__init__.py --- python-numpy-1.14.3/numpy/__init__.py 2018-04-25 21:12:00.000000000 +0000 +++ python-numpy-1.14.5/numpy/__init__.py 2018-06-12 18:28:52.000000000 +0000 @@ -197,3 +197,27 @@ # but do not use them, we define them here for backward compatibility. oldnumeric = 'removed' numarray = 'removed' + + def _sanity_check(): + """ + Quick sanity checks for common bugs caused by environment. + There are some cases (e.g., the wrong BLAS ABI) that cause wrong + results under specific runtime conditions that are not necessarily + achieved during test suite runs, and it is useful to catch those early. + + See https://github.com/numpy/numpy/issues/8577 and other + similar bug reports. + + """ + try: + x = ones(2, dtype=float32) + if not abs(x.dot(x) - 2.0) < 1e-5: + raise AssertionError() + except AssertionError: + msg = ("The current Numpy installation ({!r}) fails to " + "pass simple sanity checks. This can be caused for example " + "by incorrect BLAS library being linked in.") + raise RuntimeError(msg.format(__file__)) + + _sanity_check() + del _sanity_check diff -Nru python-numpy-1.14.3/numpy/lib/_iotools.py python-numpy-1.14.5/numpy/lib/_iotools.py --- python-numpy-1.14.3/numpy/lib/_iotools.py 2018-04-23 22:28:56.000000000 +0000 +++ python-numpy-1.14.5/numpy/lib/_iotools.py 2018-06-12 17:31:56.000000000 +0000 @@ -205,7 +205,11 @@ # def __init__(self, delimiter=None, comments='#', autostrip=True, encoding=None): + delimiter = _decode_line(delimiter) + comments = _decode_line(comments) + self.comments = comments + # Delimiter is a character if (delimiter is None) or isinstance(delimiter, basestring): delimiter = delimiter or None diff -Nru python-numpy-1.14.3/numpy/lib/tests/test__iotools.py python-numpy-1.14.5/numpy/lib/tests/test__iotools.py --- python-numpy-1.14.3/numpy/lib/tests/test__iotools.py 2018-04-25 21:12:00.000000000 +0000 +++ python-numpy-1.14.5/numpy/lib/tests/test__iotools.py 2018-06-12 18:28:52.000000000 +0000 @@ -53,6 +53,11 @@ test = LineSplitter(',')(strg) assert_equal(test, ['1', '2', '3', '4', '', '5']) + # gh-11028 bytes comment/delimiters should get decoded + strg = b" 1,2,3,4,,5 % test" + test = LineSplitter(delimiter=b',', comments=b'%')(strg) + assert_equal(test, ['1', '2', '3', '4', '', '5']) + def test_constant_fixed_width(self): "Test LineSplitter w/ fixed-width fields" strg = " 1 2 3 4 5 # test" diff -Nru python-numpy-1.14.3/numpy/linalg/tests/test_linalg.py python-numpy-1.14.5/numpy/linalg/tests/test_linalg.py --- python-numpy-1.14.3/numpy/linalg/tests/test_linalg.py 2018-04-25 21:12:00.000000000 +0000 +++ python-numpy-1.14.5/numpy/linalg/tests/test_linalg.py 2018-06-12 18:28:52.000000000 +0000 @@ -7,7 +7,8 @@ import sys import itertools import traceback -import warnings +import textwrap +import subprocess import numpy as np from numpy import array, single, double, csingle, cdouble, dot, identity @@ -1632,6 +1633,40 @@ raise SkipTest('Numpy xerbla not linked in.') +def test_sdot_bug_8577(): + # Regression test that loading certain other libraries does not + # result to wrong results in float32 linear algebra. + # + # There's a bug gh-8577 on OSX that can trigger this, and perhaps + # there are also other situations in which it occurs. + # + # Do the check in a separate process. + + bad_libs = ['PyQt5.QtWidgets', 'IPython'] + + template = textwrap.dedent(""" + import sys + {before} + try: + import {bad_lib} + except ImportError: + sys.exit(0) + {after} + x = np.ones(2, dtype=np.float32) + sys.exit(0 if np.allclose(x.dot(x), 2.0) else 1) + """) + + for bad_lib in bad_libs: + code = template.format(before="import numpy as np", after="", + bad_lib=bad_lib) + subprocess.check_call([sys.executable, "-c", code]) + + # Swapped import order + code = template.format(after="import numpy as np", before="", + bad_lib=bad_lib) + subprocess.check_call([sys.executable, "-c", code]) + + class TestMultiDot(object): def test_basic_function_with_three_arguments(self): diff -Nru python-numpy-1.14.3/numpy/linalg/umath_linalg.c.src python-numpy-1.14.5/numpy/linalg/umath_linalg.c.src --- python-numpy-1.14.3/numpy/linalg/umath_linalg.c.src 2018-04-25 21:12:00.000000000 +0000 +++ python-numpy-1.14.5/numpy/linalg/umath_linalg.c.src 2018-06-12 18:28:52.000000000 +0000 @@ -368,17 +368,11 @@ ***************************************************************************** */ -static NPY_INLINE void * -offset_ptr(void* ptr, ptrdiff_t offset) -{ - return (void*)((npy_uint8*)ptr + offset); -} - static NPY_INLINE int get_fp_invalid_and_clear(void) { int status; - status = npy_clear_floatstatus(); + status = npy_clear_floatstatus_barrier((char*)&status); return !!(status & NPY_FPE_INVALID); } @@ -389,7 +383,7 @@ npy_set_floatstatus_invalid(); } else { - npy_clear_floatstatus(); + npy_clear_floatstatus_barrier((char*)&error_occurred); } } @@ -553,104 +547,6 @@ params->row_strides, params->column_strides); } - -static NPY_INLINE float -FLOAT_add(float op1, float op2) -{ - return op1 + op2; -} - -static NPY_INLINE double -DOUBLE_add(double op1, double op2) -{ - return op1 + op2; -} - -static NPY_INLINE COMPLEX_t -CFLOAT_add(COMPLEX_t op1, COMPLEX_t op2) -{ - COMPLEX_t result; - result.array[0] = op1.array[0] + op2.array[0]; - result.array[1] = op1.array[1] + op2.array[1]; - - return result; -} - -static NPY_INLINE DOUBLECOMPLEX_t -CDOUBLE_add(DOUBLECOMPLEX_t op1, DOUBLECOMPLEX_t op2) -{ - DOUBLECOMPLEX_t result; - result.array[0] = op1.array[0] + op2.array[0]; - result.array[1] = op1.array[1] + op2.array[1]; - - return result; -} - -static NPY_INLINE float -FLOAT_mul(float op1, float op2) -{ - return op1*op2; -} - -static NPY_INLINE double -DOUBLE_mul(double op1, double op2) -{ - return op1*op2; -} - - -static NPY_INLINE COMPLEX_t -CFLOAT_mul(COMPLEX_t op1, COMPLEX_t op2) -{ - COMPLEX_t result; - result.array[0] = op1.array[0]*op2.array[0] - op1.array[1]*op2.array[1]; - result.array[1] = op1.array[1]*op2.array[0] + op1.array[0]*op2.array[1]; - - return result; -} - -static NPY_INLINE DOUBLECOMPLEX_t -CDOUBLE_mul(DOUBLECOMPLEX_t op1, DOUBLECOMPLEX_t op2) -{ - DOUBLECOMPLEX_t result; - result.array[0] = op1.array[0]*op2.array[0] - op1.array[1]*op2.array[1]; - result.array[1] = op1.array[1]*op2.array[0] + op1.array[0]*op2.array[1]; - - return result; -} - -static NPY_INLINE float -FLOAT_mulc(float op1, float op2) -{ - return op1*op2; -} - -static NPY_INLINE double -DOUBLE_mulc(float op1, float op2) -{ - return op1*op2; -} - -static NPY_INLINE COMPLEX_t -CFLOAT_mulc(COMPLEX_t op1, COMPLEX_t op2) -{ - COMPLEX_t result; - result.array[0] = op1.array[0]*op2.array[0] + op1.array[1]*op2.array[1]; - result.array[1] = op1.array[0]*op2.array[1] - op1.array[1]*op2.array[0]; - - return result; -} - -static NPY_INLINE DOUBLECOMPLEX_t -CDOUBLE_mulc(DOUBLECOMPLEX_t op1, DOUBLECOMPLEX_t op2) -{ - DOUBLECOMPLEX_t result; - result.array[0] = op1.array[0]*op2.array[0] + op1.array[1]*op2.array[1]; - result.array[1] = op1.array[0]*op2.array[1] - op1.array[1]*op2.array[0]; - - return result; -} - static NPY_INLINE void print_FLOAT(npy_float s) { diff -Nru python-numpy-1.14.3/numpy/version.py python-numpy-1.14.5/numpy/version.py --- python-numpy-1.14.3/numpy/version.py 2018-04-27 21:26:56.000000000 +0000 +++ python-numpy-1.14.5/numpy/version.py 2018-06-12 18:29:44.000000000 +0000 @@ -2,10 +2,10 @@ # THIS FILE IS GENERATED FROM NUMPY SETUP.PY # # To compare versions robustly, use `numpy.lib.NumpyVersion` -short_version = '1.14.3' -version = '1.14.3' -full_version = '1.14.3' -git_revision = '73299826729be58cec179b52c656adfcaefada93' +short_version = '1.14.5' +version = '1.14.5' +full_version = '1.14.5' +git_revision = 'd3348c1123d3862a42d50a7fee14e50b268944a4' release = True if not release: diff -Nru python-numpy-1.14.3/PKG-INFO python-numpy-1.14.5/PKG-INFO --- python-numpy-1.14.3/PKG-INFO 2018-04-27 21:27:00.000000000 +0000 +++ python-numpy-1.14.5/PKG-INFO 2018-06-12 18:29:46.000000000 +0000 @@ -1,6 +1,6 @@ Metadata-Version: 1.2 Name: numpy -Version: 1.14.3 +Version: 1.14.5 Summary: NumPy: array processing for numbers, strings, records, and objects. Home-page: http://www.numpy.org Author: Travis E. Oliphant et al. diff -Nru python-numpy-1.14.3/setup.py python-numpy-1.14.5/setup.py --- python-numpy-1.14.3/setup.py 2018-04-27 20:34:34.000000000 +0000 +++ python-numpy-1.14.5/setup.py 2018-06-12 18:28:52.000000000 +0000 @@ -63,7 +63,7 @@ MAJOR = 1 MINOR = 14 -MICRO = 3 +MICRO = 5 ISRELEASED = True VERSION = '%d.%d.%d' % (MAJOR, MINOR, MICRO)