From 70f97a5040e20642b68e45d30e030a89ac89e665 Mon Sep 17 00:00:00 2001 From: Stephan Hoyer Date: Tue, 1 Jan 2019 21:57:07 -0800 Subject: [PATCH 0001/4713] TST: check exception details in refguide_check.py xref GH-12548 --- numpy/core/multiarray.py | 5 +++-- tools/refguide_check.py | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/numpy/core/multiarray.py b/numpy/core/multiarray.py index 4c2715892bd4..3cc882055265 100644 --- a/numpy/core/multiarray.py +++ b/numpy/core/multiarray.py @@ -893,8 +893,9 @@ def bincount(x, weights=None, minlength=None): >>> np.bincount(np.arange(5, dtype=float)) Traceback (most recent call last): - File "", line 1, in - TypeError: array cannot be safely cast to required type + ... + TypeError: Cannot cast array data from dtype('float64') to dtype('int64') + according to the rule 'safe' A possible use of ``bincount`` is to perform sums over variable-size chunks of an array, using the ``weights`` keyword. diff --git a/tools/refguide_check.py b/tools/refguide_check.py index 3d885e37f045..6326a859b21a 100644 --- a/tools/refguide_check.py +++ b/tools/refguide_check.py @@ -613,7 +613,7 @@ def _run_doctests(tests, full_name, verbose, doctest_warnings): Returns: list of [(success_flag, output), ...] """ - flags = NORMALIZE_WHITESPACE | ELLIPSIS | IGNORE_EXCEPTION_DETAIL + flags = NORMALIZE_WHITESPACE | ELLIPSIS runner = DTRunner(full_name, checker=Checker(), optionflags=flags, verbose=verbose) From 13dd42b784f3530753e53260c18f6aa2c957de5a Mon Sep 17 00:00:00 2001 From: Peter Andreas Entschev Date: Tue, 15 Oct 2019 22:36:04 +0200 Subject: [PATCH 0002/4713] NEP: Proposal for array creation dispatching with `__array_function__` This NEP proposes the introduction of a `like=` argument. The argument is to be added to all array creation functions. This allows the user to pass a reference array that will use `__array_function__` protocol to dispatch such functions to downstream libraries. --- ...-creation-dispatch-with-array-function.rst | 184 ++++++++++++++++++ 1 file changed, 184 insertions(+) create mode 100644 doc/neps/nep-0033-array-creation-dispatch-with-array-function.rst diff --git a/doc/neps/nep-0033-array-creation-dispatch-with-array-function.rst b/doc/neps/nep-0033-array-creation-dispatch-with-array-function.rst new file mode 100644 index 000000000000..886a346863bc --- /dev/null +++ b/doc/neps/nep-0033-array-creation-dispatch-with-array-function.rst @@ -0,0 +1,184 @@ +=========================================================== +NEP 33 — Array Creation Dispatching With __array_function__ +=========================================================== + +:Author: Peter Andreas Entschev +:Status: Draft +:Type: Standards Track +:Created: 2019-10-15 +:Updated: 2019-10-15 +:Resolution: + +Abstract +-------- + +We propose the introduction of a new keyword argument ``like=`` to all array +creation functions to permit dispatching of such functions by the +``__array_function__`` protocol, addressing one of the protocol shortcomings, +as described by NEP-18 [1]_. + +Detailed description +-------------------- + +The introduction of the ``__array_function__`` protocol allowed downstream +library developers to use NumPy as a dispatching API. However, the protocol +did not -- and did not intend to -- address the creation of arrays by downstream +libraries, preventing those libraries from using such important functionality in +that context. + +Other NEPs have been written to address parts of that limitation, such as the +introduction of the ``__duckarray__`` protocol in NEP-30 [2]_, and the +introduction of an overriding mechanism called ``uarray`` by NEP-31 [3]_. + +The purpose of this NEP is to address that shortcoming in a simple and +straighforward way: introduce a new ``like=`` keyword argument, similar to how +the ``empty_like`` family of functions work. When array creation functions +receive such an argument, they will trigger the ``__array_function__`` protocol, +and call the downstream library's own array creation function implementation. +The ``like=`` argument, as its own name suggests, shall be used solely for the +purpose of identifying where to dispatch. In contrast to the way +``__array_function__`` has been used so far (the first argument identifies where +to dispatch), and to avoid breaking NumPy's API with regards to array creation, +the new ``like=`` keyword shall be used for the purpose of dispatching. + +Usage Guidance +~~~~~~~~~~~~~~ + +The new ``like=`` keyword is solely intended to identify the downstream library +where to dispatch and the object is used only as reference, meaning that no +modifications, copies or processing will be performed on that object. + +We expect that this functionality will be mostly useful to library developers, +allowing them to create new arrays for internal usage based on arrays passed +by the user, preventing unnecessary creation of NumPy arrays that will +ultimately lead to an additional conversion into a downstream array type. + +Implementation +-------------- + +The implementation requires introducing a new ``like=`` keyword to all existing +array creation functions of NumPy. As of the writing of this NEP, a complete +list of array creation functions can be found in [4]_. + +This newly proposed keyword shall be removed by the ``__array_function__`` +mechanism from the keyword dictionary before dispatching. The purpose for this +is twofold: + +1. The object will have no use in the downstream library's implementation; and +2. Simplifies adoption of array creation by those libraries already opting-in + to implement the ``__array_function__`` protocol, thus removing the + requirement to explicitly opt-in for all array creation functions. + +Downstream libraries thus shall _NOT_ include the ``like=`` keyword to their +array creation APIs, which is a NumPy-exclusive keyword. + +Function Dispatching +~~~~~~~~~~~~~~~~~~~~ + +There are two different cases to dispatch: Python functions, and C functions. +To permit ``__array_function__`` dispatching, one possible implementation is to +decorate Python functions with ``overrides.array_function_dispatch``, but C +functions have a different requirement, which we shall describe shortly. + +The example below shows a suggestion on how the ``asarray`` could be decorated +with ``overrides.array_function_dispatch``: + +.. code:: python + + def _asarray_decorator(a, dtype=None, order=None, like=None): + if like is not None: + return (like,) + return (a,) + + @set_module('numpy') + @array_function_dispatch(_asarray_decorator) + def asarray(a, dtype=None, order=None, like=None): + return array(a, dtype, copy=False, order=order) + +Note in the example above that the implementation remains unchanged, the only +difference is the decoration, which uses the new ``_asarray_decorator`` function +to instruct the ``__array_function__`` protocol to dispatch if ``like`` is not +``None``. + +We will now look at a C function example, and since ``asarray`` is anyway a +specialization of ``array``, we will use the latter as an example now. As +``array`` is a C function, currently all NumPy does regarding its Python source +is to import the function and adjust its ``__module__`` to ``numpy``. The +function will now be decorated with a specialization of +``overrides.array_function_from_dispatcher``, which shall take care of adjusting +the module too. + +.. code:: python + + array_function_nodocs_from_c_func_and_dispatcher = functools.partial( + overrides.array_function_from_dispatcher, + module='numpy', docs_from_dispatcher=False, verify=False) + + @array_function_nodocs_from_c_func_and_dispatcher(_multiarray_umath.array) + def array(a, dtype=None, copy=True, order='K', subok=False, ndmin=0, like=None): + if like is not None: + return (like,) + return (a,) + +There are two downsides to the implementation above for C functions: + +1. It creates another Python function call; and +2. To follow current implementation standards, documentation should be attached + directly to the Python source code. + +Alternatively for C functions, the implementation of ``like=`` could be moved +into the C implementation itself. This is not the primary suggestion here due +to its inherent complexity which would be difficult too long to describe in its +entirety here, and too tedious for the reader. However, we leave that as an +option open for discussion. + +Usage +----- + +The purpose of this NEP is to keep things simple. Similarly, we can exemplify +the usage of ``like=`` in a simple way. Imagine you have an array of ones +created by a downstream library, such as CuPy. What you need now is a new array +that can be created using the NumPy API, but that will in fact be created by +the downstream library, a simple way to achieve that is shown below. + +.. code:: python + + x = cupy.ones(2) + np.array([1, 3, 5], like=x) # Returns cupy.ndarray + +As a second example, we could also create an array of evenly spaced numbers +using a Dask identity matrix as reference: + +.. code:: python + + x = dask.array.eye(3) + np.linspace(0, 2, like=x) # Returns dask.array + + +Compatibility +------------- + +This proposal does not raise any backward compatibility issues within NumPy, +given that it only introduces a new keyword argument to existing array creation +functions. + +Downstream libraries will benefit from the ``like=`` argument automatically, +that is, without any explicit changes in their codebase. The only requirement +is that they already implement the ``__array_function__`` protocol, as +described by NEP-18 [2]_. + +References and Footnotes +------------------------ + +.. [1] `NEP-18 - A dispatch mechanism for NumPy's high level array functions `_. + +.. [2] `NEP 30 — Duck Typing for NumPy Arrays - Implementation `_. + +.. [3] `NEP 31 — Context-local and global overrides of the NumPy API `_. + +.. [4] `Array creation routines `_. + +Copyright +--------- + +This document has been placed in the public domain. From edd16e6664c48dbabd5e0446ff8306fc7a0862b5 Mon Sep 17 00:00:00 2001 From: Peter Andreas Entschev Date: Wed, 16 Oct 2019 11:21:10 +0200 Subject: [PATCH 0003/4713] MAINT: fix implementation example of NEP-33 --- ...p-0033-array-creation-dispatch-with-array-function.rst | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/doc/neps/nep-0033-array-creation-dispatch-with-array-function.rst b/doc/neps/nep-0033-array-creation-dispatch-with-array-function.rst index 886a346863bc..639ed621005e 100644 --- a/doc/neps/nep-0033-array-creation-dispatch-with-array-function.rst +++ b/doc/neps/nep-0033-array-creation-dispatch-with-array-function.rst @@ -86,9 +86,7 @@ with ``overrides.array_function_dispatch``: .. code:: python def _asarray_decorator(a, dtype=None, order=None, like=None): - if like is not None: - return (like,) - return (a,) + return (like,) @set_module('numpy') @array_function_dispatch(_asarray_decorator) @@ -116,9 +114,7 @@ the module too. @array_function_nodocs_from_c_func_and_dispatcher(_multiarray_umath.array) def array(a, dtype=None, copy=True, order='K', subok=False, ndmin=0, like=None): - if like is not None: - return (like,) - return (a,) + return (like,) There are two downsides to the implementation above for C functions: From f4f02e7ff8500265d5e4b89072b5c246e842ee55 Mon Sep 17 00:00:00 2001 From: Peter Andreas Entschev Date: Wed, 16 Oct 2019 11:59:05 +0200 Subject: [PATCH 0004/4713] MAINT: cite few examples of array creation functions in NEP-33 --- ...033-array-creation-dispatch-with-array-function.rst | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/doc/neps/nep-0033-array-creation-dispatch-with-array-function.rst b/doc/neps/nep-0033-array-creation-dispatch-with-array-function.rst index 639ed621005e..5b8fd802c8ee 100644 --- a/doc/neps/nep-0033-array-creation-dispatch-with-array-function.rst +++ b/doc/neps/nep-0033-array-creation-dispatch-with-array-function.rst @@ -57,8 +57,14 @@ Implementation -------------- The implementation requires introducing a new ``like=`` keyword to all existing -array creation functions of NumPy. As of the writing of this NEP, a complete -list of array creation functions can be found in [4]_. +array creation functions of NumPy. As examples of functions that would add this +new argument (but not limited to) we can cite those taking array-like objects +such as ``array`` and ``asarray``, functions that create arrays based on +numerical ranges such as ``range`` and ``linspace``, as well as the ``empty`` +family of functions, even though that may be redundant, since there exists +already specializations for those with the naming format ``empty_like``. As of +the writing of this NEP, a complete list of array creation functions can be +found in [4]_. This newly proposed keyword shall be removed by the ``__array_function__`` mechanism from the keyword dictionary before dispatching. The purpose for this From 296129225bb95bfd983059e047051a00fded6cac Mon Sep 17 00:00:00 2001 From: Peter Andreas Entschev Date: Mon, 4 Nov 2019 14:27:56 +0100 Subject: [PATCH 0005/4713] MAINT: change array creation dispatching with `__array_function__` to NEP-35 --- ...=> nep-0035-array-creation-dispatch-with-array-function.rst} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename doc/neps/{nep-0033-array-creation-dispatch-with-array-function.rst => nep-0035-array-creation-dispatch-with-array-function.rst} (99%) diff --git a/doc/neps/nep-0033-array-creation-dispatch-with-array-function.rst b/doc/neps/nep-0035-array-creation-dispatch-with-array-function.rst similarity index 99% rename from doc/neps/nep-0033-array-creation-dispatch-with-array-function.rst rename to doc/neps/nep-0035-array-creation-dispatch-with-array-function.rst index 5b8fd802c8ee..884dbe0ccbf0 100644 --- a/doc/neps/nep-0033-array-creation-dispatch-with-array-function.rst +++ b/doc/neps/nep-0035-array-creation-dispatch-with-array-function.rst @@ -1,5 +1,5 @@ =========================================================== -NEP 33 — Array Creation Dispatching With __array_function__ +NEP 35 — Array Creation Dispatching With __array_function__ =========================================================== :Author: Peter Andreas Entschev From c5da77d47309b6bf11f13f3b2e760f9b21423427 Mon Sep 17 00:00:00 2001 From: Sebastian Berg Date: Mon, 18 Nov 2019 16:13:06 -0800 Subject: [PATCH 0006/4713] API: Use `ResultType` in `PyArray_ConvertToCommonType` This slightly modifies the behaviour of `np.choose` (practically a bug fix) and the public function itself. The function is not used within e.g. SciPy, so the small performance hit of this implementation is probably insignificant. The change should help clean up dtypes a bit, since the whole "scalar cast" logic is brittle and should be deprecated/removed, and this is probably one of the few places actually using it. The choose change means that: ``` np.choose([0], (1000, np.array([1], dtype=np.uint8))) ``` will actually return a value of 1000 (the dtype not being uint8). --- .../upcoming_changes/14933.compatibility.rst | 10 ++ doc/source/reference/c-api/array.rst | 20 ++-- numpy/core/src/multiarray/convert_datatype.c | 105 +++++------------- numpy/core/tests/test_multiarray.py | 9 ++ 4 files changed, 59 insertions(+), 85 deletions(-) create mode 100644 doc/release/upcoming_changes/14933.compatibility.rst diff --git a/doc/release/upcoming_changes/14933.compatibility.rst b/doc/release/upcoming_changes/14933.compatibility.rst new file mode 100644 index 000000000000..b939fec7f01f --- /dev/null +++ b/doc/release/upcoming_changes/14933.compatibility.rst @@ -0,0 +1,10 @@ +Scalar promotion in ``PyArray_ConvertToCommonType`` +--------------------------------------------------- + +The promotion of mixed scalars and arrays in ``PyArray_ConvertToCommonType`` +has been changed to adhere to those used by ``np.result_type``. +This means that input such as ``(1000, np.array([1], dtype=np.uint8)))`` +will now return ``uint16`` dtypes. In most cases the behaviour is unchanged. +Note that the use of this C-API function is generally discouarged. +This also fixes ``np.choose`` to behave the same way as the rest of NumPy +in this respect. diff --git a/doc/source/reference/c-api/array.rst b/doc/source/reference/c-api/array.rst index 0530a5747a9b..c910efa603ca 100644 --- a/doc/source/reference/c-api/array.rst +++ b/doc/source/reference/c-api/array.rst @@ -1255,14 +1255,18 @@ Converting data types Convert a sequence of Python objects contained in *op* to an array of ndarrays each having the same data type. The type is selected - based on the typenumber (larger type number is chosen over a - smaller one) ignoring objects that are only scalars. The length of - the sequence is returned in *n*, and an *n* -length array of - :c:type:`PyArrayObject` pointers is the return value (or ``NULL`` if an - error occurs). The returned array must be freed by the caller of - this routine (using :c:func:`PyDataMem_FREE` ) and all the array objects - in it ``DECREF`` 'd or a memory-leak will occur. The example - template-code below shows a typically usage: + in the same way as `PyArray_ResultType`. The length of the sequence is + returned in *n*, and an *n* -length array of :c:type:`PyArrayObject` + pointers is the return value (or ``NULL`` if an error occurs). + The returned array must be freed by the caller of this routine + (using :c:func:`PyDataMem_FREE` ) and all the array objects in it + ``DECREF`` 'd or a memory-leak will occur. The example template-code + below shows a typically usage: + + .. versionchanged:: 1.18.0 + A mix of scalars and zero-dimensional arrays now produces a type + capable of holding the scalar value. + Previously priority was given to the dtype of the arrays. .. code-block:: c diff --git a/numpy/core/src/multiarray/convert_datatype.c b/numpy/core/src/multiarray/convert_datatype.c index 025c660138dc..11609092e8ee 100644 --- a/numpy/core/src/multiarray/convert_datatype.c +++ b/numpy/core/src/multiarray/convert_datatype.c @@ -2115,15 +2115,19 @@ PyArray_ObjectType(PyObject *op, int minimum_type) /* Raises error when len(op) == 0 */ -/*NUMPY_API*/ +/*NUMPY_API + * + * This function is only used in one place within NumPy and should + * generally be avoided. It is provided mainly for backward compatibility. + * + * The user of the function has to free the returned array. + */ NPY_NO_EXPORT PyArrayObject ** PyArray_ConvertToCommonType(PyObject *op, int *retn) { - int i, n, allscalars = 0; + int i, n; + PyArray_Descr *common_descr = NULL; PyArrayObject **mps = NULL; - PyArray_Descr *intype = NULL, *stype = NULL; - PyArray_Descr *newtype = NULL; - NPY_SCALARKIND scalarkind = NPY_NOSCALAR, intypekind = NPY_NOSCALAR; *retn = n = PySequence_Length(op); if (n == 0) { @@ -2159,94 +2163,41 @@ PyArray_ConvertToCommonType(PyObject *op, int *retn) } for (i = 0; i < n; i++) { - PyObject *otmp = PySequence_GetItem(op, i); - if (otmp == NULL) { + /* Convert everything to an array, this could be optimized away */ + PyObject *tmp = PySequence_GetItem(op, i); + if (tmp == NULL) { goto fail; } - if (!PyArray_CheckAnyScalar(otmp)) { - newtype = PyArray_DescrFromObject(otmp, intype); - Py_DECREF(otmp); - Py_XDECREF(intype); - if (newtype == NULL) { - goto fail; - } - intype = newtype; - intypekind = PyArray_ScalarKind(intype->type_num, NULL); - } - else { - newtype = PyArray_DescrFromObject(otmp, stype); - Py_DECREF(otmp); - Py_XDECREF(stype); - if (newtype == NULL) { - goto fail; - } - stype = newtype; - scalarkind = PyArray_ScalarKind(newtype->type_num, NULL); - mps[i] = (PyArrayObject *)Py_None; - Py_INCREF(Py_None); - } - } - if (intype == NULL) { - /* all scalars */ - allscalars = 1; - intype = stype; - Py_INCREF(intype); - for (i = 0; i < n; i++) { - Py_XDECREF(mps[i]); - mps[i] = NULL; - } - } - else if ((stype != NULL) && (intypekind != scalarkind)) { - /* - * we need to upconvert to type that - * handles both intype and stype - * also don't forcecast the scalars. - */ - if (!PyArray_CanCoerceScalar(stype->type_num, - intype->type_num, - scalarkind)) { - newtype = PyArray_PromoteTypes(intype, stype); - Py_XDECREF(intype); - intype = newtype; - if (newtype == NULL) { - goto fail; - } - } - for (i = 0; i < n; i++) { - Py_XDECREF(mps[i]); - mps[i] = NULL; + + mps[i] = (PyArrayObject *)PyArray_FROM_O(tmp); + Py_DECREF(tmp); + if (mps[i] == NULL) { + goto fail; } } + common_descr = PyArray_ResultType(n, mps, 0, NULL); + if (common_descr == NULL) { + goto fail; + } - /* Make sure all arrays are actual array objects. */ + /* Make sure all arrays are contiguous and have the correct dtype. */ for (i = 0; i < n; i++) { int flags = NPY_ARRAY_CARRAY; - PyObject *otmp = PySequence_GetItem(op, i); + PyArrayObject *tmp = mps[i]; - if (otmp == NULL) { - goto fail; - } - if (!allscalars && ((PyObject *)(mps[i]) == Py_None)) { - /* forcecast scalars */ - flags |= NPY_ARRAY_FORCECAST; - Py_DECREF(Py_None); - } - Py_INCREF(intype); - mps[i] = (PyArrayObject*)PyArray_FromAny(otmp, intype, 0, 0, - flags, NULL); - Py_DECREF(otmp); + Py_INCREF(common_descr); + mps[i] = (PyArrayObject *)PyArray_FromArray(tmp, common_descr, flags); + Py_DECREF(tmp); if (mps[i] == NULL) { goto fail; } } - Py_DECREF(intype); - Py_XDECREF(stype); + Py_DECREF(common_descr); return mps; fail: - Py_XDECREF(intype); - Py_XDECREF(stype); + Py_XDECREF(common_descr); *retn = 0; for (i = 0; i < n; i++) { Py_XDECREF(mps[i]); diff --git a/numpy/core/tests/test_multiarray.py b/numpy/core/tests/test_multiarray.py index 218106a63b22..6c496a028c22 100644 --- a/numpy/core/tests/test_multiarray.py +++ b/numpy/core/tests/test_multiarray.py @@ -6488,6 +6488,15 @@ def test_broadcast2(self): A = np.choose(self.ind, (self.x, self.y2)) assert_equal(A, [[2, 2, 3], [2, 2, 3]]) + @pytest.mark.parametrize("ops", + [(1000, np.array([1], dtype=np.uint8)), + (-1, np.array([1], dtype=np.uint8)), + (1., np.float32(3)), + (1., np.array([3], dtype=np.float32))],) + def test_output_dtype(self, ops): + expected_dt = np.result_type(*ops) + assert(np.choose([0], ops).dtype == expected_dt) + class TestRepeat(object): def setup(self): From a483acce85e6a35a5da0f46aeddd05b33f6d612c Mon Sep 17 00:00:00 2001 From: Sebastian Berg Date: Mon, 25 Nov 2019 11:16:28 -0600 Subject: [PATCH 0007/4713] BUG: Make ``ediff1d`` kwarg casting consistent This reverts commit c088383cb290ca064d456e89d79177a0e234cb8d and uses the same kind casting rule for the additional keyword arguments ``to_end`` and ``to_begin``. This results in slightly more leniant behaviour for integers (which can now have overflows that are hidden), but fixes an issue with the handling of NaN. Generally, this behaviour seems more conistent with what NumPy does elsewhere. The Overflow issue exists similar in many other places and should be solved by integer overflow warning machinery while the actual cast takes place. Closes gh-13103 --- .../upcoming_changes/14981.compatibility.rst | 10 +++++++ numpy/core/tests/test_regression.py | 8 ++++-- numpy/lib/arraysetops.py | 26 +++++++++---------- numpy/lib/tests/test_arraysetops.py | 19 +++++++++----- 4 files changed, 41 insertions(+), 22 deletions(-) create mode 100644 doc/release/upcoming_changes/14981.compatibility.rst diff --git a/doc/release/upcoming_changes/14981.compatibility.rst b/doc/release/upcoming_changes/14981.compatibility.rst new file mode 100644 index 000000000000..90cf866f21b4 --- /dev/null +++ b/doc/release/upcoming_changes/14981.compatibility.rst @@ -0,0 +1,10 @@ +`np.ediff1d` casting behaviour with ``to_end`` and ``to_begin`` +--------------------------------------------------------------- + +`np.ediff1d` now uses the ``"same_kind"`` casting rule for +its additional ``to_end`` and ``to_begin`` arguments. This +ensures type safety except when the input array has a smaller +integer type than ``to_begin`` or ``to_end``. +In rare cases, the behaviour will be more strict than it was +previously in 1.16 and 1.17. This is necessary to solve issues +with floating point NaN. diff --git a/numpy/core/tests/test_regression.py b/numpy/core/tests/test_regression.py index d5de0f2b2971..b215163ae641 100644 --- a/numpy/core/tests/test_regression.py +++ b/numpy/core/tests/test_regression.py @@ -2467,8 +2467,11 @@ def test_eff1d_casting(self): x = np.array([1, 2, 4, 7, 0], dtype=np.int16) res = np.ediff1d(x, to_begin=-99, to_end=np.array([88, 99])) assert_equal(res, [-99, 1, 2, 3, -7, 88, 99]) - assert_raises(ValueError, np.ediff1d, x, to_begin=(1<<20)) - assert_raises(ValueError, np.ediff1d, x, to_end=(1<<20)) + + # The use of safe casting means, that 1<<20 is cast unsafely, an + # error may be better, but currently there is no mechanism for it. + res = np.ediff1d(x, to_begin=(1<<20), to_end=(1<<20)) + assert_equal(res, [0, 1, 2, 3, -7, 0]) def test_pickle_datetime64_array(self): # gh-12745 (would fail with pickle5 installed) @@ -2513,3 +2516,4 @@ def test_to_ctypes(self): assert arr.size * arr.itemsize > 2 ** 31 c_arr = np.ctypeslib.as_ctypes(arr) assert_equal(c_arr._length_, arr.size) + diff --git a/numpy/lib/arraysetops.py b/numpy/lib/arraysetops.py index 2309f7e4217a..d65316598d69 100644 --- a/numpy/lib/arraysetops.py +++ b/numpy/lib/arraysetops.py @@ -94,8 +94,7 @@ def ediff1d(ary, to_end=None, to_begin=None): # force a 1d array ary = np.asanyarray(ary).ravel() - # enforce propagation of the dtype of input - # ary to returned result + # enforce that the dtype of `ary` is used for the output dtype_req = ary.dtype # fast track default case @@ -105,22 +104,23 @@ def ediff1d(ary, to_end=None, to_begin=None): if to_begin is None: l_begin = 0 else: - _to_begin = np.asanyarray(to_begin, dtype=dtype_req) - if not np.all(_to_begin == to_begin): - raise ValueError("cannot convert 'to_begin' to array with dtype " - "'%r' as required for input ary" % dtype_req) - to_begin = _to_begin.ravel() + to_begin = np.asanyarray(to_begin) + if not np.can_cast(to_begin, dtype_req, casting="same_kind"): + raise TypeError("dtype of `to_end` must be compatible " + "with input `ary` under the `same_kind` rule.") + + to_begin = to_begin.ravel() l_begin = len(to_begin) if to_end is None: l_end = 0 else: - _to_end = np.asanyarray(to_end, dtype=dtype_req) - # check that casting has not overflowed - if not np.all(_to_end == to_end): - raise ValueError("cannot convert 'to_end' to array with dtype " - "'%r' as required for input ary" % dtype_req) - to_end = _to_end.ravel() + to_end = np.asanyarray(to_end) + if not np.can_cast(to_end, dtype_req, casting="same_kind"): + raise TypeError("dtype of `to_end` must be compatible " + "with input `ary` under the `same_kind` rule.") + + to_end = to_end.ravel() l_end = len(to_end) # do the calculation in place and copy to_begin and to_end diff --git a/numpy/lib/tests/test_arraysetops.py b/numpy/lib/tests/test_arraysetops.py index fd21a7f76288..1d38d8d27981 100644 --- a/numpy/lib/tests/test_arraysetops.py +++ b/numpy/lib/tests/test_arraysetops.py @@ -135,9 +135,9 @@ def test_ediff1d(self): None, np.nan), # should fail because attempting - # to downcast to smaller int type: - (np.array([1, 2, 3], dtype=np.int16), - np.array([5, 1<<20, 2], dtype=np.int32), + # to downcast to int type: + (np.array([1, 2, 3], dtype=np.int64), + np.array([5, 7, 2], dtype=np.float32), None), # should fail because attempting to cast # two special floating point values @@ -152,8 +152,8 @@ def test_ediff1d_forbidden_type_casts(self, ary, prepend, append): # specifically, raise an appropriate # Exception when attempting to append or # prepend with an incompatible type - msg = 'cannot convert' - with assert_raises_regex(ValueError, msg): + msg = 'must be compatible' + with assert_raises_regex(TypeError, msg): ediff1d(ary=ary, to_end=append, to_begin=prepend) @@ -163,9 +163,13 @@ def test_ediff1d_forbidden_type_casts(self, ary, prepend, append): "append," "expected", [ (np.array([1, 2, 3], dtype=np.int16), - 0, + 2**16, # will be cast to int16 under same kind rule. + 2**16 + 4, + np.array([0, 1, 1, 4], dtype=np.int16)), + (np.array([1, 2, 3], dtype=np.float32), + np.array([5], dtype=np.float64), None, - np.array([0, 1, 1], dtype=np.int16)), + np.array([5, 1, 1], dtype=np.float32)), (np.array([1, 2, 3], dtype=np.int32), 0, 0, @@ -187,6 +191,7 @@ def test_ediff1d_scalar_handling(self, to_end=append, to_begin=prepend) assert_equal(actual, expected) + assert actual.dtype == expected.dtype def test_isin(self): From 6fa0ff8e56e7e09f0c1cdbce2da338be073947e9 Mon Sep 17 00:00:00 2001 From: Eric Wieser Date: Sun, 1 Dec 2019 16:13:14 +0000 Subject: [PATCH 0008/4713] ENH: Show the incorrect type in the fortran error message I just got this error while hacking some scipy internals, and had nowhere near enough information to debug it. This is a little closer to useful. --- numpy/f2py/src/fortranobject.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/numpy/f2py/src/fortranobject.c b/numpy/f2py/src/fortranobject.c index 8aa55555d2a5..eb1050dd7108 100644 --- a/numpy/f2py/src/fortranobject.c +++ b/numpy/f2py/src/fortranobject.c @@ -839,9 +839,10 @@ PyArrayObject* array_from_pyobj(const int type_num, if ((intent & F2PY_INTENT_INOUT) || (intent & F2PY_INTENT_INPLACE) || (intent & F2PY_INTENT_CACHE)) { - PyErr_SetString(PyExc_TypeError, - "failed to initialize intent(inout|inplace|cache) " - "array, input not an array"); + PyErr_Format(PyExc_TypeError, + "failed to initialize intent(inout|inplace|cache) " + "array, input '%s' object is not an array", + Py_TYPE(obj)->tp_name); return NULL; } From 3c6bbd7b43bf584aeef780a9e42acf2ecce7b179 Mon Sep 17 00:00:00 2001 From: Eric Wieser Date: Sun, 1 Dec 2019 16:27:48 +0000 Subject: [PATCH 0009/4713] ENH: Chain exceptions when converting python objects to fortran Note that since we now need `npy_3kcompat.h`, we can delete all duplicated lines in this file We preserve the original exception type for compatibility with old code here. --- numpy/core/include/numpy/npy_3kcompat.h | 1 + numpy/f2py/rules.py | 12 ++++++++---- numpy/f2py/src/fortranobject.h | 25 +------------------------ 3 files changed, 10 insertions(+), 28 deletions(-) diff --git a/numpy/core/include/numpy/npy_3kcompat.h b/numpy/core/include/numpy/npy_3kcompat.h index 832bc05995a3..7ed263796c60 100644 --- a/numpy/core/include/numpy/npy_3kcompat.h +++ b/numpy/core/include/numpy/npy_3kcompat.h @@ -45,6 +45,7 @@ static NPY_INLINE int PyInt_Check(PyObject *op) { #define PyInt_AsLong PyLong_AsLong #define PyInt_AS_LONG PyLong_AsLong #define PyInt_AsSsize_t PyLong_AsSsize_t +#define PyNumber_Int PyNumber_Long /* NOTE: * diff --git a/numpy/f2py/rules.py b/numpy/f2py/rules.py index f2f713bde251..28eb9da30871 100755 --- a/numpy/f2py/rules.py +++ b/numpy/f2py/rules.py @@ -1064,8 +1064,10 @@ '\tcapi_#varname#_tmp = array_from_pyobj(#atype#,#varname#_Dims,#varname#_Rank,capi_#varname#_intent,#varname#_capi);'}, """\ \tif (capi_#varname#_tmp == NULL) { -\t\tif (!PyErr_Occurred()) -\t\t\tPyErr_SetString(#modulename#_error,\"failed in converting #nth# `#varname#\' of #pyname# to C/Fortran array\" ); +\t\tPyObject *exc, *val, *tb; +\t\tPyErr_Fetch(&exc, &val, &tb); +\t\tPyErr_SetString(exc ? exc : #modulename#_error,\"failed in converting #nth# `#varname#\' of #pyname# to C/Fortran array\" ); +\t\tnpy_PyErr_ChainExceptionsCause(exc, val, tb); \t} else { \t\t#varname# = (#ctype# *)(PyArray_DATA(capi_#varname#_tmp)); """, @@ -1081,8 +1083,10 @@ \t\t\twhile ((_i = nextforcomb())) \t\t\t\t#varname#[capi_i++] = #init#; /* fortran way */ \t\t} else { -\t\t\tif (!PyErr_Occurred()) -\t\t\t\tPyErr_SetString(#modulename#_error,\"Initialization of #nth# #varname# failed (initforcomb).\"); +\t\t\tPyObject *exc, *val, *tb; +\t\t\tPyErr_Fetch(&exc, &val, &tb); +\t\t\tPyErr_SetString(exc ? exc : #modulename#_error,\"Initialization of #nth# #varname# failed (initforcomb).\"); +\t\t\tnpy_PyErr_ChainExceptionsCause(exc, val, tb); \t\t\tf2py_success = 0; \t\t} \t} diff --git a/numpy/f2py/src/fortranobject.h b/numpy/f2py/src/fortranobject.h index 5d0dcf676337..21f1977eb3b2 100644 --- a/numpy/f2py/src/fortranobject.h +++ b/numpy/f2py/src/fortranobject.h @@ -11,30 +11,7 @@ extern "C" { #endif #define PY_ARRAY_UNIQUE_SYMBOL _npy_f2py_ARRAY_API #include "numpy/arrayobject.h" - -/* - * Python 3 support macros - */ -#if PY_VERSION_HEX >= 0x03000000 -#define PyString_Check PyBytes_Check -#define PyString_GET_SIZE PyBytes_GET_SIZE -#define PyString_AS_STRING PyBytes_AS_STRING -#define PyString_FromString PyBytes_FromString -#define PyUString_FromStringAndSize PyUnicode_FromStringAndSize -#define PyString_ConcatAndDel PyBytes_ConcatAndDel -#define PyString_AsString PyBytes_AsString - -#define PyInt_Check PyLong_Check -#define PyInt_FromLong PyLong_FromLong -#define PyInt_AS_LONG PyLong_AsLong -#define PyInt_AsLong PyLong_AsLong - -#define PyNumber_Int PyNumber_Long - -#else - -#define PyUString_FromStringAndSize PyString_FromStringAndSize -#endif +#include "numpy/npy_3kcompat.h" #ifdef F2PY_REPORT_ATEXIT From 5b9ad3687e3315a46e19e1b3fd31b74967244afb Mon Sep 17 00:00:00 2001 From: jfbu Date: Mon, 2 Dec 2019 15:00:44 +0100 Subject: [PATCH 0010/4713] [DOC] LaTeX: Fix preamble Memo: latex_preamble got removed from Sphinx at 1.6.1, and old LaTeX package expdlist requires a fix else it breaks LaTeX if a description list is in a table cell, and it causes anyhow many LaTeX complaints about Underfull box (badness 10000). The fix for these complaints is copied over from https://github.com/scipy/scipy/commit/c881fdea7a7ef7c518b789 and it turns out it is also a fix for the crash in case a description list is in a table.. --- doc/source/conf.py | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/doc/source/conf.py b/doc/source/conf.py index 83cecc917ea8..09770535b698 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -178,15 +178,28 @@ def setup(app): } # Additional stuff for the LaTeX preamble. -latex_preamble = r''' -\usepackage{amsmath} -\DeclareUnicodeCharacter{00A0}{\nobreakspace} - +latex_elements['preamble'] = r''' % In the parameters section, place a newline after the Parameters % header \usepackage{expdlist} \let\latexdescription=\description \def\description{\latexdescription{}{} \breaklabel} +% but expdlist old LaTeX package requires fixes: +% 1) remove extra space +\usepackage{etoolbox} +\makeatletter +\patchcmd\@item{{\@breaklabel} }{{\@breaklabel}}{}{} +\makeatother +% 2) fix bug in expdlist's way of breaking the line after long item label +\makeatletter +\def\breaklabel{% + \def\@breaklabel{% + \leavevmode\par + % now a hack because Sphinx inserts \leavevmode after term node + \def\leavevmode{\def\leavevmode{\unhbox\voidb@x}}% + }% +} +\makeatother % Make Examples/etc section headers smaller and more compact \makeatletter From f343dc0e5cf9eca84abc427277c7784b980637f6 Mon Sep 17 00:00:00 2001 From: jfbu Date: Mon, 2 Dec 2019 20:34:49 +0100 Subject: [PATCH 0011/4713] [DOC] LaTeX: do PDF build with --halt-on-error option --- doc/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/Makefile b/doc/Makefile index 3c32cb811943..74272fa50db6 100644 --- a/doc/Makefile +++ b/doc/Makefile @@ -217,7 +217,7 @@ latex-build: generate mkdir -p build/latex build/doctrees $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) build/latex $(FILES) $(PYTHON) postprocess.py tex build/latex/*.tex - perl -pi -e 's/\t(latex.*|pdflatex) (.*)/\t-$$1 -interaction batchmode $$2/' build/latex/Makefile + perl -pi -e 's/LATEXOPTS =/LATEXOPTS ?= --halt-on-error/' build/latex/Makefile @echo @echo "Build finished; the LaTeX files are in build/latex." @echo "Run \`make all-pdf' or \`make all-ps' in that directory to" \ From 522e6241c5d95522345ebe2611e8d006388e575c Mon Sep 17 00:00:00 2001 From: mattip Date: Tue, 3 Dec 2019 08:30:50 +0200 Subject: [PATCH 0012/4713] BUG: add endfunction, endsubroutine to valid fortran end words --- numpy/f2py/crackfortran.py | 3 ++- numpy/f2py/tests/test_crackfortran.py | 39 +++++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 numpy/f2py/tests/test_crackfortran.py diff --git a/numpy/f2py/crackfortran.py b/numpy/f2py/crackfortran.py index 2aaf5d7c6c12..2db4a47e86ca 100755 --- a/numpy/f2py/crackfortran.py +++ b/numpy/f2py/crackfortran.py @@ -558,7 +558,8 @@ def readfortrancode(ffile, dowithline=show, istop=1): r'|module(?!\s*procedure)|python\s*module|interface|type(?!\s*\()' beginpattern90 = re.compile( beforethisafter % ('', groupbegins90, groupbegins90, '.*'), re.I), 'begin' -groupends = r'end|endprogram|endblockdata|endmodule|endpythonmodule|endinterface' +groupends = (r'end|endprogram|endblockdata|endmodule|endpythonmodule|' + r'endinterface|endsubroutine|endfunction') endpattern = re.compile( beforethisafter % ('', groupends, groupends, r'[\w\s]*'), re.I), 'end' # endifs='end\s*(if|do|where|select|while|forall)' diff --git a/numpy/f2py/tests/test_crackfortran.py b/numpy/f2py/tests/test_crackfortran.py new file mode 100644 index 000000000000..8af1b4d80b78 --- /dev/null +++ b/numpy/f2py/tests/test_crackfortran.py @@ -0,0 +1,39 @@ +from __future__ import division, absolute_import, print_function + +import pytest + +import numpy as np +from numpy.testing import assert_array_equal +from . import util + + +class TestNoSpace(util.F2PyTest): + code = """ + subroutine subb(k) + real(8), intent(inout) :: k(:) + k=k+1 + endsubroutine + + subroutine subc(w,k) + real(8), intent(in) :: w(:) + real(8), intent(out) :: k(size(w)) + k=w+1 + endsubroutine + + function t0(value) + character value + character t0 + t0 = value + endfunction + + """ + + def test_module(self): + k = np.array([1, 2, 3], dtype = np.float) + w = np.array([1, 2, 3], dtype = np.float) + self.module.subb(k) + assert_array_equal(k, w + 1) + self.module.subc([w, k]) + assert_array_equal(k, w + 1) + assert self.module.t0(23) == b'2' + From 60608572d7740dabf287d2536684eacbc46561ab Mon Sep 17 00:00:00 2001 From: mattip Date: Tue, 3 Dec 2019 09:09:06 +0200 Subject: [PATCH 0013/4713] DOC: fix outstanding typo in NumPy version --- numpy/f2py/cfuncs.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/numpy/f2py/cfuncs.py b/numpy/f2py/cfuncs.py index ccb7b3a329f7..cede0611950a 100644 --- a/numpy/f2py/cfuncs.py +++ b/numpy/f2py/cfuncs.py @@ -542,7 +542,7 @@ 'ARRSIZE'] = '#define ARRSIZE(dims,rank) (_PyArray_multiply_list(dims,rank))' cppmacros['OLDPYNUM'] = """\ #ifdef OLDPYNUM -#error You need to install NumPy version 13 or higher. See https://scipy.org/install.html +#error You need to install NumPy version 0.13 or higher. See https://scipy.org/install.html #endif """ ################# C functions ############### From f6ab00eb61d3db15522f373462d8984e792edeb8 Mon Sep 17 00:00:00 2001 From: mattip Date: Tue, 3 Dec 2019 12:08:05 +0200 Subject: [PATCH 0014/4713] MAINT: fixes from review --- numpy/f2py/tests/test_crackfortran.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/numpy/f2py/tests/test_crackfortran.py b/numpy/f2py/tests/test_crackfortran.py index 8af1b4d80b78..941696be398e 100644 --- a/numpy/f2py/tests/test_crackfortran.py +++ b/numpy/f2py/tests/test_crackfortran.py @@ -8,6 +8,8 @@ class TestNoSpace(util.F2PyTest): + # issue gh-15035: add handling for endsubroutine, endfunction with no space + # between "end" and the block name code = """ subroutine subb(k) real(8), intent(inout) :: k(:) @@ -25,12 +27,11 @@ class TestNoSpace(util.F2PyTest): character t0 t0 = value endfunction - """ def test_module(self): - k = np.array([1, 2, 3], dtype = np.float) - w = np.array([1, 2, 3], dtype = np.float) + k = np.array([1, 2, 3], dtype=np.float64) + w = np.array([1, 2, 3], dtype=np.float64) self.module.subb(k) assert_array_equal(k, w + 1) self.module.subc([w, k]) From f0efb2a80565795afbdb2fce6428c0e623f16048 Mon Sep 17 00:00:00 2001 From: Charles Harris Date: Tue, 3 Dec 2019 17:10:55 -0700 Subject: [PATCH 0015/4713] DOC: Update HOWTO_RELEASE.rst.txt - Remove obsolete bits. - Update Python versions. - Add some blank lines for clarity - Make list markup uniform. [ci skip] --- doc/HOWTO_RELEASE.rst.txt | 133 ++++++++++++++++++++------------------ 1 file changed, 69 insertions(+), 64 deletions(-) diff --git a/doc/HOWTO_RELEASE.rst.txt b/doc/HOWTO_RELEASE.rst.txt index 53359f0a2ebc..f0231293f267 100644 --- a/doc/HOWTO_RELEASE.rst.txt +++ b/doc/HOWTO_RELEASE.rst.txt @@ -3,143 +3,147 @@ NumPy. Current build and release info ============================== - The current info on building and releasing NumPy and SciPy is scattered in several places. It should be summarized in one place, updated, and where necessary described in more detail. The sections below list all places where useful info can be found. + Source tree ----------- -* INSTALL.rst.txt -* release.sh -* pavement.py +- INSTALL.rst.txt +- release.sh +- pavement.py + NumPy Docs ---------- -* https://github.com/numpy/numpy/blob/master/doc/HOWTO_RELEASE.rst.txt -* http://projects.scipy.org/numpy/wiki/MicrosoftToolchainSupport (dead link) +- https://github.com/numpy/numpy/blob/master/doc/HOWTO_RELEASE.rst.txt +- http://projects.scipy.org/numpy/wiki/MicrosoftToolchainSupport (dead link) + SciPy.org wiki -------------- -* https://www.scipy.org/Installing_SciPy and links on that page. -* http://new.scipy.org/building/windows.html (dead link) +- https://www.scipy.org/Installing_SciPy and links on that page. +- http://new.scipy.org/building/windows.html (dead link) + Doc wiki -------- -* http://docs.scipy.org/numpy/docs/numpy-docs/user/install.rst/ (dead link) +- http://docs.scipy.org/numpy/docs/numpy-docs/user/install.rst/ (dead link) + Release Scripts --------------- -* https://github.com/numpy/numpy-vendor +- https://github.com/numpy/numpy-vendor + Supported platforms and versions ================================ - Python 2.7 and >=3.4 are the currently supported versions when building from source. We test NumPy against all these versions every time we merge code to master. Binary installers may be available for a subset of these versions (see below). + OS X ---- - Python 2.7 and >=3.4 are the versions for which we provide binary installers. OS X versions >= 10.6 are supported. We build binary wheels for OSX that are compatible with Python.org Python, system Python, homebrew and macports - see this `OSX wheel building summary `_ for details. + Windows ------- - We build 32- and 64-bit wheels for Python 2.7, 3.4, 3.5 on Windows. Windows XP, Vista, 7, 8 and 10 are supported. We build NumPy using the MSVC compilers on Appveyor, but we are hoping to update to a `mingw-w64 toolchain `_. The Windows wheels use ATLAS for BLAS / LAPACK. + Linux ----- - We build and ship `manylinux1 `_ wheels for NumPy. Many Linux distributions include their own binary builds of NumPy. + BSD / Solaris ------------- - No binaries are provided, but successful builds on Solaris and BSD have been reported. + Tool chain ========== - We build all our wheels on cloud infrastructure - so this list of compilers is for information and debugging builds locally. See the ``.travis.yml`` and ``appveyor.yml`` scripts in the `numpy wheels`_ repo for the definitive source of the build recipes. Packages that are available using pip are noted. + Compilers --------- - The same gcc version is used as the one with which Python itself is built on each platform. At the moment this means: -* OS X builds on travis currently use `clang`. It appears that binary wheels +- OS X builds on travis currently use `clang`. It appears that binary wheels for OSX >= 10.6 can be safely built from the travis-ci OSX 10.9 VMs when building against the Python from the Python.org installers; -* Windows builds use the MSVC version corresponding to the Python being built +- Windows builds use the MSVC version corresponding to the Python being built against; -* Manylinux1 wheels use the gcc provided on the Manylinux docker images. +- Manylinux1 wheels use the gcc provided on the Manylinux docker images. You will need Cython for building the binaries. Cython compiles the ``.pyx`` files in the NumPy distribution to ``.c`` files. + Building source archives and wheels ----------------------------------- - You will need write permission for numpy-wheels in order to trigger wheel builds. -* Python(s) from `python.org `_ or linux distro. -* cython -* virtualenv (pip) -* Paver (pip) -* numpy-wheels ``_ (clone) +- Python(s) from `python.org `_ or linux distro. +- cython +- virtualenv (pip) +- Paver (pip) +- numpy-wheels ``_ (clone) + Building docs ------------- - Building the documents requires a number of latex ``.sty`` files. Install them all to avoid aggravation. -* Sphinx (pip) -* numpydoc (pip) -* Matplotlib -* Texlive (or MikTeX on Windows) +- Sphinx (pip) +- numpydoc (pip) +- Matplotlib +- Texlive (or MikTeX on Windows) + Uploading to PyPI ----------------- +- terryfy ``_ (clone). +- beautifulsoup4 (pip) +- delocate (pip) +- auditwheel (pip) +- twine (pip) -* terryfy ``_ (clone). -* beautifulsoup4 (pip) -* delocate (pip) -* auditwheel (pip) -* twine (pip) Generating author/pr lists -------------------------- - You will need a personal access token ``_ so that scripts can access the github NumPy repository. -* gitpython (pip) -* pygithub (pip) +- gitpython (pip) +- pygithub (pip) + Virtualenv ---------- - Virtualenv is a very useful tool to keep several versions of packages around. It is also used in the Paver script to build the docs. @@ -149,27 +153,28 @@ What is released Wheels ------ +We currently support Python 3.6-3.8 on Windows, OSX, and Linux -* Windows wheels for Python 2.7, 3.4, 3.5, for 32- and 64-bit, built using - Appveyor; -* Dual architecture OSX wheels built via travis-ci; -* 32- and 64-bit Manylinux1 wheels built via travis-ci. +* Windows: 32-bit and 64-bit wheels built using Appveyor; +* OSX: x64_86 OSX wheels built using travis-ci; +* Linux: 32-bit and 64-bit Manylinux1 wheels built using travis-ci. See the `numpy wheels`_ building repository for more detail. .. _numpy wheels : https://github.com/MacPython/numpy-wheels + Other ----- +- Release Notes +- Changelog -* Release Notes -* Changelog Source distribution ------------------- - We build source releases in both .zip and .tar.gz formats. + Release process =============== @@ -182,6 +187,7 @@ After a date is set, create a new maintenance/x.y.z branch, add new empty release notes for the next version in the master branch and update the Trac Milestones. + Make sure current branch builds a package correctly --------------------------------------------------- :: @@ -197,6 +203,7 @@ best to read the pavement.py script. .. note:: The following steps are repeated for the beta(s), release candidates(s) and the final release. + Check deprecations ------------------ Before the release branch is made, it should be checked that all deprecated @@ -244,6 +251,7 @@ There are three steps to the process. The C ABI version number in numpy/core/setup_common.py should only be updated for a major release. + Check the release notes ----------------------- Use `towncrier`_ to build the release note and @@ -268,6 +276,7 @@ following: .. _towncrier: https://github.com/hawkowl/towncrier + Update the release status and create a release "tag" ---------------------------------------------------- Identify the commit hash of the release, e.g. 1b2e1d63ff. @@ -325,12 +334,6 @@ to public keyservers, with a command such as:: gpg --send-keys -Apply patch to fix bogus strides --------------------------------- -NPY_RELAXED_STRIDE_CHECKING was made the default in NumPy 1.10.0 and bogus -strides are used in the development branch to smoke out problems. The -`patch `_ should be updated if -necessary and applied to the release branch to rationalize the strides. Update the version of the master branch --------------------------------------- @@ -340,15 +343,15 @@ Increment the release number in setup.py. Release candidates should have "rc1" Also create a new version hash in cversions.txt and a corresponding version define NPY_x_y_API_VERSION in numpyconfig.h + Trigger the wheel builds on travis-ci and Appveyor -------------------------------------------------- - See the `numpy wheels` repository. In that repository edit the files: -* ``.travis.yml``; -* ``appveyor.yml``. +- ``.travis.yml``; +- ``appveyor.yml``. In both cases, set the ``BUILD_COMMIT`` variable to the current release tag - e.g. ``v1.11.1``. @@ -365,19 +368,20 @@ Trigger a build by doing a commit of your edits to ``.travis.yml`` and The wheels, once built, appear at a Rackspace container pointed at by: -* http://wheels.scipy.org -* https://3f23b170c54c2533c070-1c8a9b3114517dc5fe17b7c3f8c63a43.ssl.cf2.rackcdn.com +- http://wheels.scipy.org +- https://3f23b170c54c2533c070-1c8a9b3114517dc5fe17b7c3f8c63a43.ssl.cf2.rackcdn.com The HTTP address may update first, and you should wait 15 minutes after the build finishes before fetching the binaries. + Make the release ---------------- - Build the changelog and notes for upload with:: paver write_release_and_log + Build and archive documentation ------------------------------- Do:: @@ -397,9 +401,9 @@ create an archive of the documentation in the numpy/doc repo:: # Push to numpy/doc repo git -C push + Update PyPI ----------- - The wheels and source should be uploaded to PyPI. You should upload the wheels first, and the source formats last, to make sure @@ -436,9 +440,9 @@ interface. .. _push-tag-and-commit: + Push the release tag and commit ------------------------------- - Finally, now you are confident this tag correctly defines the source code that you released you can push the tag and release commit up to github:: @@ -448,18 +452,18 @@ you released you can push the tag and release commit up to github:: where ``upstream`` points to the main https://github.com/numpy/numpy.git repository. + Update scipy.org ---------------- - A release announcement with a link to the download site should be placed in the sidebar of the front page of scipy.org. The scipy.org should be a PR at https://github.com/scipy/scipy.org. The file that needs modification is ``www/index.rst``. Search for ``News``. + Announce to the lists --------------------- - The release should be announced on the mailing lists of NumPy and SciPy, to python-announce, and possibly also those of Matplotlib, IPython and/or Pygame. @@ -468,12 +472,13 @@ During the beta/RC phase, an explicit request for testing the binaries with several other libraries (SciPy/Matplotlib/Pygame) should be posted on the mailing list. + Announce to Linux Weekly News ----------------------------- - Email the editor of LWN to let them know of the release. Directions at: https://lwn.net/op/FAQ.lwn#contact + After the final release ----------------------- After the final release is announced, a few administrative tasks are left to be From fbcb58ca2c17217f5dc85cb669ea651b7799b60c Mon Sep 17 00:00:00 2001 From: Charles Harris Date: Tue, 3 Dec 2019 16:45:09 -0700 Subject: [PATCH 0016/4713] REL: Update master after 1.18.x branch. Apart from the usual modifications, this - Removes a release note snippet added after towncrier was run - Removes testing on Python 3.5 as it is dropped for 1.19.x. --- .travis.yml | 1 - azure-pipelines.yml | 5 ----- doc/release/upcoming_changes/14794.deprecation.rst | 7 ------- doc/source/release.rst | 1 + numpy/core/code_generators/cversions.txt | 1 + numpy/core/include/numpy/numpyconfig.h | 1 + setup.py | 7 +++---- 7 files changed, 6 insertions(+), 17 deletions(-) delete mode 100644 doc/release/upcoming_changes/14794.deprecation.rst diff --git a/.travis.yml b/.travis.yml index 64b7be051996..4afac959d7a8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -43,7 +43,6 @@ matrix: - stage: Initial tests python: 3.8 - - python: 3.5 - python: 3.6 - python: 3.7 diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 9e1e52952d63..29fc6c614bc8 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -156,11 +156,6 @@ stages: PYTHON_ARCH: 'x86' TEST_MODE: fast BITS: 32 - Python35-64bit-full: - PYTHON_VERSION: '3.5' - PYTHON_ARCH: 'x64' - TEST_MODE: full - BITS: 64 Python36-64bit-full: PYTHON_VERSION: '3.6' PYTHON_ARCH: 'x64' diff --git a/doc/release/upcoming_changes/14794.deprecation.rst b/doc/release/upcoming_changes/14794.deprecation.rst deleted file mode 100644 index b84bc1c61d89..000000000000 --- a/doc/release/upcoming_changes/14794.deprecation.rst +++ /dev/null @@ -1,7 +0,0 @@ -Deprecate automatic ``dtype=object`` for ragged input ------------------------------------------------------ -Calling ``np.array([[1, [1, 2, 3]])`` will issue a ``DeprecationWarning`` as -per `NEP 34`_. Users should explicitly use ``dtype=object`` to avoid the -warning. - -.. _`NEP 34`: https://numpy.org/neps/nep-0034.html diff --git a/doc/source/release.rst b/doc/source/release.rst index 0343275a5bbc..26373ad07abb 100644 --- a/doc/source/release.rst +++ b/doc/source/release.rst @@ -5,6 +5,7 @@ Release Notes .. toctree:: :maxdepth: 3 + 1.19.0 1.18.0 1.17.4 1.17.3 diff --git a/numpy/core/code_generators/cversions.txt b/numpy/core/code_generators/cversions.txt index 72d2af8b986b..5daa52d79019 100644 --- a/numpy/core/code_generators/cversions.txt +++ b/numpy/core/code_generators/cversions.txt @@ -49,4 +49,5 @@ # Add PyUFunc_FromFuncAndDataAndSignatureAndIdentity to ufunc_funcs_api. # Version 13 (NumPy 1.17) No change. # Version 13 (NumPy 1.18) No change. +# Version 13 (NumPy 1.19) No change. 0x0000000d = 5b0e8bbded00b166125974fc71e80a33 diff --git a/numpy/core/include/numpy/numpyconfig.h b/numpy/core/include/numpy/numpyconfig.h index 4bca82f9f5fc..4df4ea43820c 100644 --- a/numpy/core/include/numpy/numpyconfig.h +++ b/numpy/core/include/numpy/numpyconfig.h @@ -40,5 +40,6 @@ #define NPY_1_16_API_VERSION 0x00000008 #define NPY_1_17_API_VERSION 0x00000008 #define NPY_1_18_API_VERSION 0x00000008 +#define NPY_1_19_API_VERSION 0x00000008 #endif diff --git a/setup.py b/setup.py index 46c95d6e63cc..43f9521b5938 100755 --- a/setup.py +++ b/setup.py @@ -27,8 +27,8 @@ import textwrap -if sys.version_info[:2] < (3, 5): - raise RuntimeError("Python version >= 3.5 required.") +if sys.version_info[:2] < (3, 6): + raise RuntimeError("Python version >= 3.6 required.") import builtins @@ -41,7 +41,6 @@ Programming Language :: C Programming Language :: Python Programming Language :: Python :: 3 -Programming Language :: Python :: 3.5 Programming Language :: Python :: 3.6 Programming Language :: Python :: 3.7 Programming Language :: Python :: 3.8 @@ -56,7 +55,7 @@ """ MAJOR = 1 -MINOR = 18 +MINOR = 19 MICRO = 0 ISRELEASED = False VERSION = '%d.%d.%d' % (MAJOR, MINOR, MICRO) From bd1adc3b6bb97e0fceada63617eb91fccc97f3ec Mon Sep 17 00:00:00 2001 From: Sebastian Berg Date: Tue, 3 Dec 2019 21:21:40 -0600 Subject: [PATCH 0017/4713] TST: Add test for object method (and general unary) loops (#15040) * TST: Add test for object method (and general unary) loops These loops should give the same results as when run on the equivalent numeric/floatingpoint values. Adds additional tests for gh-15036 --- numpy/core/tests/test_ufunc.py | 40 +++++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/numpy/core/tests/test_ufunc.py b/numpy/core/tests/test_ufunc.py index d0173c76df33..e629945fa385 100644 --- a/numpy/core/tests/test_ufunc.py +++ b/numpy/core/tests/test_ufunc.py @@ -18,6 +18,11 @@ from numpy.compat import pickle +UNARY_UFUNCS = [obj for obj in np.core.umath.__dict__.values() + if isinstance(obj, np.ufunc)] +UNARY_OBJECT_UFUNCS = [uf for uf in UNARY_UFUNCS if "O->O" in uf.types] + + class TestUfuncKwargs(object): def test_kwarg_exact(self): assert_raises(TypeError, np.add, 1, 2, castingx='safe') @@ -124,7 +129,7 @@ def test_unary_PyUFunc_O_O(self): x = np.ones(10, dtype=object) assert_(np.all(np.abs(x) == 1)) - def test_unary_PyUFunc_O_O_method(self, foo=foo): + def test_unary_PyUFunc_O_O_method_simple(self, foo=foo): x = np.full(10, foo(), dtype=object) assert_(np.all(np.conjugate(x) == True)) @@ -140,6 +145,39 @@ def test_binary_PyUFunc_On_Om_method(self, foo=foo): x = np.full((10, 2, 3), foo(), dtype=object) assert_(np.all(np.logical_xor(x, x))) + def test_python_complex_conjugate(self): + # The conjugate ufunc should fall back to calling the method: + arr = np.array([1+2j, 3-4j], dtype="O") + assert isinstance(arr[0], complex) + res = np.conjugate(arr) + assert res.dtype == np.dtype("O") + assert_array_equal(res, np.array([1-2j, 3+4j], dtype="O")) + + @pytest.mark.parametrize("ufunc", UNARY_OBJECT_UFUNCS) + def test_unary_PyUFunc_O_O_method_full(self, ufunc): + """Compare the result of the object loop with non-object one""" + val = np.float64(np.pi/4) + + class MyFloat(np.float64): + def __getattr__(self, attr): + try: + return super().__getattr__(attr) + except AttributeError: + return lambda: getattr(np.core.umath, attr)(val) + + num_arr = np.array([val], dtype=np.float64) + obj_arr = np.array([MyFloat(val)], dtype="O") + + with np.errstate(all="raise"): + try: + res_num = ufunc(num_arr) + except Exception as exc: + with assert_raises(type(exc)): + ufunc(obj_arr) + else: + res_obj = ufunc(obj_arr) + assert_array_equal(res_num.astype("O"), res_obj) + class TestUfunc(object): def test_pickle(self): From 47fbdc1f8c9ed7ec79dfc7cdbb1affd453e84997 Mon Sep 17 00:00:00 2001 From: mattip Date: Wed, 4 Dec 2019 07:59:22 +0200 Subject: [PATCH 0018/4713] API, DOC: change names to multivariate_hypergeometric, improve docs --- doc/source/reference/random/c-api.rst | 24 ++++++------------- doc/source/reference/random/extending.rst | 2 +- .../core/include/numpy/random/distributions.h | 4 ++-- numpy/random/_generator.pyx | 16 ++++++------- .../src/distributions/random_mvhg_count.c | 4 ++-- .../src/distributions/random_mvhg_marginals.c | 4 ++-- 6 files changed, 22 insertions(+), 32 deletions(-) diff --git a/doc/source/reference/random/c-api.rst b/doc/source/reference/random/c-api.rst index 2a9de04dc86c..0d60f4d9e7ff 100644 --- a/doc/source/reference/random/c-api.rst +++ b/doc/source/reference/random/c-api.rst @@ -3,25 +3,15 @@ Cython API for random .. currentmodule:: numpy.random -Typed versions of many of the `Generator` and `BitGenerator` methods can be -accessed directly from Cython: the complete list is given below. +Typed versions of many of the `Generator` and `BitGenerator` methods as well as +the classes themselves can be accessed directly from Cython via -The ``_bit_generator`` module is usable via:: +.. code-block:: cython - cimport numpy.random._bit_generator - -It provides function pointers for quickly accessing the next bytes in the -`BitGenerator` via a :c:type:`bitgen_t` struct. - -The ``_generator`` module is usable via:: - - cimport numpy.random._generator - -It provides low-level functions for various distributions. All the functions -require a ``bitgen_t`` BitGenerator structure. + cimport numpy.random C API for random ---------------------- +---------------- Access to various distributions is available via Cython or C-wrapper libraries like CFFI. All the functions accept a :c:type:`bitgen_t` as their first argument. @@ -180,9 +170,9 @@ The functions are named with the following conventions: .. c:function:: void random_multinomial(bitgen_t *bitgen_state, npy_int64 n, npy_int64 *mnix, double *pix, npy_intp d, binomial_t *binomial) -.. c:function:: int random_mvhg_count(bitgen_t *bitgen_state, npy_int64 total, size_t num_colors, npy_int64 *colors, npy_int64 nsample, size_t num_variates, npy_int64 *variates) +.. c:function:: int random_multivariate_hypergeometric_count(bitgen_t *bitgen_state, npy_int64 total, size_t num_colors, npy_int64 *colors, npy_int64 nsample, size_t num_variates, npy_int64 *variates) -.. c:function:: void random_mvhg_marginals(bitgen_t *bitgen_state, npy_int64 total, size_t num_colors, npy_int64 *colors, npy_int64 nsample, size_t num_variates, npy_int64 *variates) +.. c:function:: void random_multivariate_hypergeometric_marginals(bitgen_t *bitgen_state, npy_int64 total, size_t num_colors, npy_int64 *colors, npy_int64 nsample, size_t num_variates, npy_int64 *variates) Generate a single integer diff --git a/doc/source/reference/random/extending.rst b/doc/source/reference/random/extending.rst index 12311379d60f..442102caacf1 100644 --- a/doc/source/reference/random/extending.rst +++ b/doc/source/reference/random/extending.rst @@ -49,7 +49,7 @@ RNG structure. :start-after: example 2 These functions along with a minimal setup file are included in the -`examples` folder, ``numpy.random.examples``. +`examples` folder, ``numpy.random._examples``. CFFI ==== diff --git a/numpy/core/include/numpy/random/distributions.h b/numpy/core/include/numpy/random/distributions.h index 0e69fc508f50..c474c4d14a3d 100644 --- a/numpy/core/include/numpy/random/distributions.h +++ b/numpy/core/include/numpy/random/distributions.h @@ -169,14 +169,14 @@ DECLDIR void random_multinomial(bitgen_t *bitgen_state, RAND_INT_TYPE n, RAND_IN double *pix, npy_intp d, binomial_t *binomial); /* multivariate hypergeometric, "count" method */ -DECLDIR int random_mvhg_count(bitgen_t *bitgen_state, +DECLDIR int random_multivariate_hypergeometric_count(bitgen_t *bitgen_state, int64_t total, size_t num_colors, int64_t *colors, int64_t nsample, size_t num_variates, int64_t *variates); /* multivariate hypergeometric, "marginals" method */ -DECLDIR void random_mvhg_marginals(bitgen_t *bitgen_state, +DECLDIR void random_multivariate_hypergeometric_marginals(bitgen_t *bitgen_state, int64_t total, size_t num_colors, int64_t *colors, int64_t nsample, diff --git a/numpy/random/_generator.pyx b/numpy/random/_generator.pyx index 74b379da8395..d76cde44c811 100644 --- a/numpy/random/_generator.pyx +++ b/numpy/random/_generator.pyx @@ -124,12 +124,12 @@ cdef extern from "numpy/random/distributions.h": void random_multinomial(bitgen_t *bitgen_state, int64_t n, int64_t *mnix, double *pix, np.npy_intp d, binomial_t *binomial) nogil - int random_mvhg_count(bitgen_t *bitgen_state, + int random_multivariate_hypergeometric_count(bitgen_t *bitgen_state, int64_t total, size_t num_colors, int64_t *colors, int64_t nsample, size_t num_variates, int64_t *variates) nogil - void random_mvhg_marginals(bitgen_t *bitgen_state, + void random_multivariate_hypergeometric_marginals(bitgen_t *bitgen_state, int64_t total, size_t num_colors, int64_t *colors, int64_t nsample, @@ -4010,18 +4010,18 @@ cdef class Generator: if method == 'count': with self.lock, nogil: - result = random_mvhg_count(&self._bitgen, total, - num_colors, colors_ptr, nsamp, - num_variates, variates_ptr) + result = random_multivariate_hypergeometric_count(&self._bitgen, + total, num_colors, colors_ptr, nsamp, + num_variates, variates_ptr) if result == -1: raise MemoryError("Insufficent memory for multivariate_" "hypergeometric with method='count' and " "sum(colors)=%d" % total) else: with self.lock, nogil: - random_mvhg_marginals(&self._bitgen, total, - num_colors, colors_ptr, nsamp, - num_variates, variates_ptr) + random_multivariate_hypergeometric_marginals(&self._bitgen, + total, num_colors, colors_ptr, nsamp, + num_variates, variates_ptr) return variates def dirichlet(self, object alpha, size=None): diff --git a/numpy/random/src/distributions/random_mvhg_count.c b/numpy/random/src/distributions/random_mvhg_count.c index 0c46ea417ad2..7cbed1f9e0fc 100644 --- a/numpy/random/src/distributions/random_mvhg_count.c +++ b/numpy/random/src/distributions/random_mvhg_count.c @@ -5,7 +5,7 @@ #include "numpy/random/distributions.h" /* - * random_mvhg_count + * random_multivariate_hypergeometric_count * * Draw variates from the multivariate hypergeometric distribution-- * the "count" algorithm. @@ -57,7 +57,7 @@ * * the product num_variates * num_colors does not overflow */ -int random_mvhg_count(bitgen_t *bitgen_state, +int random_multivariate_hypergeometric_count(bitgen_t *bitgen_state, int64_t total, size_t num_colors, int64_t *colors, int64_t nsample, diff --git a/numpy/random/src/distributions/random_mvhg_marginals.c b/numpy/random/src/distributions/random_mvhg_marginals.c index 7e4c24988ada..809d129deb4e 100644 --- a/numpy/random/src/distributions/random_mvhg_marginals.c +++ b/numpy/random/src/distributions/random_mvhg_marginals.c @@ -8,7 +8,7 @@ /* - * random_mvhg_marginals + * random_multivariate_hypergeometric_marginals * * Draw samples from the multivariate hypergeometric distribution-- * the "marginals" algorithm. @@ -95,7 +95,7 @@ * * the product num_variates * num_colors does not overflow */ -void random_mvhg_marginals(bitgen_t *bitgen_state, +void random_multivariate_hypergeometric_marginals(bitgen_t *bitgen_state, int64_t total, size_t num_colors, int64_t *colors, int64_t nsample, From aed6f9b38b8785c4b583fef13fb9f391d73b69d0 Mon Sep 17 00:00:00 2001 From: jfbu Date: Wed, 4 Dec 2019 09:56:46 +0100 Subject: [PATCH 0019/4713] Update LaTeX build instructions --- doc/source/docs/howto_build_docs.rst | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/doc/source/docs/howto_build_docs.rst b/doc/source/docs/howto_build_docs.rst index 6deacda5cc93..f46070d78147 100644 --- a/doc/source/docs/howto_build_docs.rst +++ b/doc/source/docs/howto_build_docs.rst @@ -5,7 +5,7 @@ Building the NumPy API and reference docs ========================================= We currently use Sphinx_ for generating the API and reference -documentation for NumPy. You will need Sphinx 1.8.3 <= 1.8.5. +documentation for NumPy. You will need Sphinx >= 2.0.0. If you only want to get the documentation, note that pre-built versions can be found at @@ -57,7 +57,9 @@ To build the PDF documentation, do instead:: make latex make -C build/latex all-pdf -You will need to have Latex installed for this. +You will need to have Latex installed for this, inclusive of support for +Greek letters. For example, on Ubuntu xenial ``texlive-lang-greek`` and +``cm-super`` are needed. Also ``latexmk`` is needed on non-Windows systems. Instead of the above, you can also do:: From 8f6bdf83f40c22a76f75c42b7dacf34f0229082f Mon Sep 17 00:00:00 2001 From: Pauli Virtanen Date: Wed, 4 Dec 2019 20:41:53 +0200 Subject: [PATCH 0020/4713] DOC: add missing release note for ILP64 OpenBLAS --- doc/source/release/1.18.0-notes.rst | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/doc/source/release/1.18.0-notes.rst b/doc/source/release/1.18.0-notes.rst index e0b89ba671e9..0cea811fb88b 100644 --- a/doc/source/release/1.18.0-notes.rst +++ b/doc/source/release/1.18.0-notes.rst @@ -205,6 +205,11 @@ The `numpy.expand_dims` ``axis`` keyword can now accept a tuple of axes. Previously, ``axis`` was required to be an integer. (`gh-14051 `__) +Support for 64-bit OpenBLAS with symbol suffix +---------------------------------------------- +Added support for 64-bit (ILP64) OpenBLAS compiled with +``make INTERFACE64=1 SYMBOLSUFFIX=64_``. See ``site.cfg.example`` +for details. Improvements ============ From d3f6a7eddc68c9160db695106d196cebbc8d9fd4 Mon Sep 17 00:00:00 2001 From: Pauli Virtanen Date: Wed, 4 Dec 2019 20:49:56 +0200 Subject: [PATCH 0021/4713] TST: fix up issues in requires_memory decorator Fix wrong multiplier for /proc/meminfo, and do style cleanups. --- numpy/lib/tests/test_io.py | 2 +- numpy/linalg/tests/test_linalg.py | 2 +- numpy/testing/_private/decorators.py | 4 ---- numpy/testing/_private/utils.py | 11 ++++++----- 4 files changed, 8 insertions(+), 11 deletions(-) diff --git a/numpy/lib/tests/test_io.py b/numpy/lib/tests/test_io.py index 4188265e8cb3..39fe40685943 100644 --- a/numpy/lib/tests/test_io.py +++ b/numpy/lib/tests/test_io.py @@ -576,7 +576,7 @@ def test_unicode_and_bytes_fmt(self, fmt, iotype): @pytest.mark.skipif(sys.platform=='win32', reason="large files cause problems") @pytest.mark.slow - @requires_memory(7e9) + @requires_memory(free_bytes=7e9) def test_large_zip(self): # The test takes at least 6GB of memory, writes a file larger than 4GB test_data = np.asarray([np.random.rand(np.random.randint(50,100),4) diff --git a/numpy/linalg/tests/test_linalg.py b/numpy/linalg/tests/test_linalg.py index e1590f1e76c1..bd3df1ca472d 100644 --- a/numpy/linalg/tests/test_linalg.py +++ b/numpy/linalg/tests/test_linalg.py @@ -2008,7 +2008,7 @@ def test_unsupported_commontype(): @pytest.mark.slow @pytest.mark.xfail(not HAS_LAPACK64, run=False, reason="Numpy not compiled with 64-bit BLAS/LAPACK") -@requires_memory(16e9) +@requires_memory(free_bytes=16e9) def test_blas64_dot(): n = 2**32 a = np.zeros([1, n], dtype=np.float32) diff --git a/numpy/testing/_private/decorators.py b/numpy/testing/_private/decorators.py index eab40e7c9296..24c4e385d1d1 100644 --- a/numpy/testing/_private/decorators.py +++ b/numpy/testing/_private/decorators.py @@ -15,10 +15,6 @@ """ from __future__ import division, absolute_import, print_function -import sys -import os -import re - try: # Accessing collections abstract classes from collections # has been deprecated since Python 3.3 diff --git a/numpy/testing/_private/utils.py b/numpy/testing/_private/utils.py index 4642cc0f8463..32bd738bc3f0 100644 --- a/numpy/testing/_private/utils.py +++ b/numpy/testing/_private/utils.py @@ -2417,9 +2417,10 @@ def requires_memory(free_bytes): def _parse_size(size_str): """Convert memory size strings ('12 GB' etc.) to float""" - suffixes = {'': 1.0, 'b': 1.0, - 'k': 1e3, 'm': 1e6, 'g': 1e9, 't': 1e12, - 'kb': 1e3, 'mb': 1e6, 'gb': 1e9, 'tb': 1e12} + suffixes = {'': 1, 'b': 1, + 'k': 1000, 'm': 1000**2, 'g': 1000**3, 't': 1000**4, + 'kb': 1000, 'mb': 1000**2, 'gb': 1000**3, 'tb': 1000**4, + 'kib': 1024, 'mib': 1024**2, 'gib': 1024**3, 'tib': 1024**4} size_re = re.compile(r'^\s*(\d+|\d+\.\d+)\s*({0})\s*$'.format( '|'.join(suffixes.keys())), re.I) @@ -2427,7 +2428,7 @@ def _parse_size(size_str): m = size_re.match(size_str.lower()) if not m or m.group(2) not in suffixes: raise ValueError("value {!r} not a valid size".format(size_str)) - return float(m.group(1)) * suffixes[m.group(2)] + return int(float(m.group(1)) * suffixes[m.group(2)]) def _get_mem_available(): @@ -2443,7 +2444,7 @@ def _get_mem_available(): with open('/proc/meminfo', 'r') as f: for line in f: p = line.split() - info[p[0].strip(':').lower()] = float(p[1]) * 1e3 + info[p[0].strip(':').lower()] = int(p[1]) * 1024 if 'memavailable' in info: # Linux >= 3.14 From 80cf9fd93f2c1e361b8650c0eba96d21d4a588bc Mon Sep 17 00:00:00 2001 From: Pauli Virtanen Date: Wed, 4 Dec 2019 20:51:52 +0200 Subject: [PATCH 0022/4713] BUG: distutils: remove stray debug print --- numpy/distutils/system_info.py | 1 - 1 file changed, 1 deletion(-) diff --git a/numpy/distutils/system_info.py b/numpy/distutils/system_info.py index 1bc1b1391e72..fc2902b78287 100644 --- a/numpy/distutils/system_info.py +++ b/numpy/distutils/system_info.py @@ -2062,7 +2062,6 @@ def check_symbols(self, info): %(calls)s return 0; }""") % dict(prototypes=prototypes, calls=calls) - print(s) src = os.path.join(tmpdir, 'source.c') out = os.path.join(tmpdir, 'a.out') # Add the additional "extra" arguments From 0c7cafb5e1be7dbdfe730098583cf2266bd5ed26 Mon Sep 17 00:00:00 2001 From: Sanjeev Kumar Date: Thu, 5 Dec 2019 00:35:53 +0530 Subject: [PATCH 0023/4713] Added documentation in methods --- tools/refguide_check.py | 230 ++++++++++++++++++++++++++++++++++++---- 1 file changed, 207 insertions(+), 23 deletions(-) diff --git a/tools/refguide_check.py b/tools/refguide_check.py index 2c628091f33b..162f85e7bb97 100644 --- a/tools/refguide_check.py +++ b/tools/refguide_check.py @@ -152,6 +152,17 @@ def short_path(path, cwd=None): """ Return relative or absolute path name, whichever is shortest. + + Parameters + ---------- + path: str or None + + cwd: str or None + + Returns + ------- + str + Relative path or absolute path based on current working directory """ if not isinstance(path, str): return path @@ -165,17 +176,32 @@ def short_path(path, cwd=None): def find_names(module, names_dict): - # Refguide entries: - # - # - 3 spaces followed by function name, and maybe some spaces, some - # dashes, and an explanation; only function names listed in - # refguide are formatted like this (mostly, there may be some false - # positives) - # - # - special directives, such as data and function - # - # - (scipy.constants only): quoted list - # + """ + Finds the occurences of function names, special directives like data + and functions and scipy constants in the docstrings of `module`. The + following patterns are searched for: + + * 3 spaces followed by function name, and maybe some spaces, some + dashes, and an explanation; only function names listed in + refguide are formatted like this (mostly, there may be some false + positives + * special directives, such as data and function + * (scipy.constants only): quoted list + + The `names_dict` is updated by reference and accessible in calling method + + Parameters + ---------- + module : ModuleType + The module, whose docstrings id to be searched + names_dict : dict + Dictionary which contains module name as key and a set of found + function names and directives as value + + Returns + ------- + None + """ patterns = [ r"^\s\s\s([a-z_0-9A-Z]+)(\s+-+.*)?$", r"^\.\. (?:data|function)::\s*([a-z_0-9A-Z]+)\s*$" @@ -203,7 +229,23 @@ def find_names(module, names_dict): def get_all_dict(module): - """Return a copy of the __all__ dict with irrelevant items removed.""" + """ + Return a copy of the __all__ dict with irrelevant items removed. + + Parameters + ---------- + module : ModuleType + The module whose __all__ dict has to be processed + + Returns + ------- + deprecated : list + List of callable and deprecated sub modules + not_deprecated : list + List of non callable or non deprecated sub modules + others : list + List of remaining types of sub modules + """ if hasattr(module, "__all__"): all_dict = copy.deepcopy(module.__all__) else: @@ -239,7 +281,26 @@ def get_all_dict(module): def compare(all_dict, others, names, module_name): - """Return sets of objects only in __all__, refguide, or completely missing.""" + """ + Return sets of objects only in __all__, refguide, or completely missing. + + Parameters + ---------- + all_dict : list + List of non deprecated sub modules for module_name + others : list + List of sub modules for module_name + names : set + Set of function names or special directives present in + docstring of module_name + module_name : ModuleType + + Returns + ------- + only_all : set + only_ref : set + missing : set + """ only_all = set() for name in all_dict: if name not in names: @@ -265,6 +326,17 @@ def compare(all_dict, others, names, module_name): def is_deprecated(f): + """ + Check if module `f` is deprecated + + Parameter + --------- + f : ModuleType + + Returns + ------- + bool + """ with warnings.catch_warnings(record=True) as w: warnings.simplefilter("error") try: @@ -280,6 +352,23 @@ def check_items(all_dict, names, deprecated, others, module_name, dots=True): """ Check that `all_dict` is consistent with the `names` in `module_name` For instance, that there are no deprecated or extra objects. + + Parameters + ---------- + all_dict : list + + names : set + + deprecated : list + + others : list + + module_name : ModuleType + + Returns + ------- + list + List of [(name, success_flag, output)...] """ num_all = len(all_dict) num_ref = len(names) @@ -331,6 +420,19 @@ def check_items(all_dict, names, deprecated, others, module_name, dots=True): def validate_rst_syntax(text, name, dots=True): + """ + Validates the doc string text of a module `name` + Parameters + ---------- + text : str + Docstring of module + name : str + name of module + + Returns + ------- + (bool, str) + """ if text is None: if dots: output_dot('E') @@ -407,7 +509,16 @@ def check_rest(module, names, dots=True): """ Check reStructuredText formatting of docstrings - Returns: [(name, success_flag, output), ...] + Parameters + ---------- + module : ModuleType + + names : set + + Returns + ------- + result : list + List of [(module_name, success_flag, output)...] """ try: @@ -498,6 +609,9 @@ def check_rest(module, names, dots=True): class DTRunner(doctest.DocTestRunner): + """ + The doctest runner + """ DIVIDER = "\n" def __init__(self, item_name, checker=None, verbose=None, optionflags=0): @@ -531,6 +645,9 @@ def report_failure(self, out, test, example, got): example, got) class Checker(doctest.OutputChecker): + """ + Check the docstrings + """ obj_pattern = re.compile('at 0x[0-9a-fA-F]+>') int_pattern = re.compile('^[0-9]+L?$') vanilla = doctest.OutputChecker() @@ -644,9 +761,23 @@ def _do_check(self, want, got): def _run_doctests(tests, full_name, verbose, doctest_warnings): - """Run modified doctests for the set of `tests`. + """ + Run modified doctests for the set of `tests`. + + Parameters + ---------- + tests: list - Returns: list of [(success_flag, output), ...] + full_name : str + + verbose : bool + + doctest_warning : bool + + Returns + ------- + list + List of [(success_flag, output), ...] """ flags = NORMALIZE_WHITESPACE | ELLIPSIS | IGNORE_EXCEPTION_DETAIL runner = DTRunner(full_name, checker=Checker(), optionflags=flags, @@ -711,9 +842,25 @@ def flush(self): def check_doctests(module, verbose, ns=None, dots=True, doctest_warnings=False): - """Check code in docstrings of the module's public symbols. - - Returns: list of [(item_name, success_flag, output), ...] + """ + Check code in docstrings of the module's public symbols. + + Parameters + ---------- + module : ModuleType + Name of module + verbose : bool + Should the result be verbose + ns : dict + Name space of module + dots : bool + + doctest_warnings : bool + + Returns + ------- + results : list + List of [(item_name, success_flag, output), ...] """ if ns is None: ns = dict(DEFAULT_NAMESPACE) @@ -763,13 +910,30 @@ def check_doctests(module, verbose, ns=None, def check_doctests_testfile(fname, verbose, ns=None, dots=True, doctest_warnings=False): - """Check code in a text file. + """ + Check code in a text file. Mimic `check_doctests` above, differing mostly in test discovery. (which is borrowed from stdlib's doctest.testfile here, https://github.com/python-git/python/blob/master/Lib/doctest.py) - Returns: list of [(item_name, success_flag, output), ...] + Parameters + ---------- + fname : str + File name + verbose : bool + + ns : dict + Name space + + dots : bool + + doctest_warnings : bool + + Returns + ------- + list + List of [(item_name, success_flag, output), ...] Notes ----- @@ -865,6 +1029,19 @@ def iter_included_files(base_path, verbose=0, suffixes=('.rst',)): Generator function to walk `base_path` and its subdirectories, skipping files or directories in RST_SKIPLIST, and yield each file with a suffix in `suffixes` + + Parameters + ---------- + base_path : str + Base path of the directory to be processed + verbose : int + + suffixes : tuple + + Yields + ------ + path + Path of the directory and it's sub directories """ if os.path.exists(base_path) and os.path.isfile(base_path): yield base_path @@ -914,6 +1091,9 @@ def scratch(): def init_matplotlib(): + """ + Check feasibility of matplotlib initialization. + """ global HAVE_MATPLOTLIB try: @@ -925,6 +1105,10 @@ def init_matplotlib(): def main(argv): + """ + Validates the docstrings of all the pre decided set of + modules for errors and docstring standards. + """ parser = ArgumentParser(usage=__doc__.lstrip()) parser.add_argument("module_names", metavar="SUBMODULES", default=[], nargs='*', help="Submodules to check (default: all public)") @@ -948,9 +1132,9 @@ def main(argv): os.environ['SCIPY_PIL_IMAGE_VIEWER'] = 'true' module_names = list(args.module_names) - for name in list(module_names): + for name in module_names: if name in OTHER_MODULE_DOCS: - name = OTHER_MODULE_DOCS[name] + name = OTHER_MODULE_DOCS[name] if name not in module_names: module_names.append(name) From 8b607e0e46f0316f24e09b5206748bce02cc397f Mon Sep 17 00:00:00 2001 From: mattip Date: Thu, 5 Dec 2019 08:49:31 +0200 Subject: [PATCH 0024/4713] DOC: change to link (from review) --- doc/source/reference/random/examples/cython/index.rst | 2 ++ doc/source/reference/random/extending.rst | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/doc/source/reference/random/examples/cython/index.rst b/doc/source/reference/random/examples/cython/index.rst index 9c5da9559ba8..368f5fcd5676 100644 --- a/doc/source/reference/random/examples/cython/index.rst +++ b/doc/source/reference/random/examples/cython/index.rst @@ -1,4 +1,6 @@ +.. _extending_cython_example: + Extending `numpy.random` via Cython ----------------------------------- diff --git a/doc/source/reference/random/extending.rst b/doc/source/reference/random/extending.rst index 442102caacf1..4adb90c06297 100644 --- a/doc/source/reference/random/extending.rst +++ b/doc/source/reference/random/extending.rst @@ -48,8 +48,8 @@ RNG structure. :language: cython :start-after: example 2 -These functions along with a minimal setup file are included in the -`examples` folder, ``numpy.random._examples``. +See :ref:`extending_cython_example` for a complete working example including a +minimal setup and cython files. CFFI ==== From bfca5dbe46fb4ca12ce88541fa4dd1293871ec0e Mon Sep 17 00:00:00 2001 From: Sanjeev Kumar Date: Thu, 5 Dec 2019 21:08:26 +0530 Subject: [PATCH 0025/4713] Implemented review feedbacks #14961 --- tools/refguide_check.py | 35 +++++++++++++++++++++++------------ 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/tools/refguide_check.py b/tools/refguide_check.py index 162f85e7bb97..ba045cebf71d 100644 --- a/tools/refguide_check.py +++ b/tools/refguide_check.py @@ -177,7 +177,7 @@ def short_path(path, cwd=None): def find_names(module, names_dict): """ - Finds the occurences of function names, special directives like data + Finds the occurrences of function names, special directives like data and functions and scipy constants in the docstrings of `module`. The following patterns are searched for: @@ -193,7 +193,7 @@ def find_names(module, names_dict): Parameters ---------- module : ModuleType - The module, whose docstrings id to be searched + The module, whose docstrings is to be searched names_dict : dict Dictionary which contains module name as key and a set of found function names and directives as value @@ -282,7 +282,11 @@ def get_all_dict(module): def compare(all_dict, others, names, module_name): """ - Return sets of objects only in __all__, refguide, or completely missing. + Return sets of objects from all_dict. + Will return three sets: + {in module_name.__all__}, + {in REFGUIDE*}, + and {missing from others} Parameters ---------- @@ -365,6 +369,9 @@ def check_items(all_dict, names, deprecated, others, module_name, dots=True): module_name : ModuleType + dots : bool + Whether to print a dot for each check + Returns ------- list @@ -421,14 +428,16 @@ def check_items(all_dict, names, deprecated, others, module_name, dots=True): def validate_rst_syntax(text, name, dots=True): """ - Validates the doc string text of a module `name` + Validates the doc string in a snippet of documentation + `text` from file `name` Parameters ---------- text : str - Docstring of module + Docstring text name : str - name of module - + File name for which the doc string is to be validated + dots : bool + Whether to print a dot symbol for each check Returns ------- (bool, str) @@ -518,7 +527,7 @@ def check_rest(module, names, dots=True): Returns ------- result : list - List of [(module_name, success_flag, output)...] + List of [(module_name, success_flag, output),...] """ try: @@ -776,8 +785,8 @@ def _run_doctests(tests, full_name, verbose, doctest_warnings): Returns ------- - list - List of [(success_flag, output), ...] + tuple(bool, list) + Tuple of (success, output) """ flags = NORMALIZE_WHITESPACE | ELLIPSIS | IGNORE_EXCEPTION_DETAIL runner = DTRunner(full_name, checker=Checker(), optionflags=flags, @@ -789,7 +798,9 @@ def out(msg): output.append(msg) class MyStderr(object): - """Redirect stderr to the current stdout""" + """ + Redirect stderr to the current stdout + """ def write(self, msg): if doctest_warnings: sys.stdout.write(msg) @@ -1134,7 +1145,7 @@ def main(argv): module_names = list(args.module_names) for name in module_names: if name in OTHER_MODULE_DOCS: - name = OTHER_MODULE_DOCS[name] + name = OTHER_MODULE_DOCS[name] if name not in module_names: module_names.append(name) From 0aeab48b9e914d1dc7041b7e3f3b7e575ffcbbed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20Kl=C3=B6ckner?= Date: Thu, 5 Dec 2019 17:24:33 -0600 Subject: [PATCH 0026/4713] DOC: Fix statement about norms (#15050) The "0.5-norm" violates the triangle inequality because its unit ball is nonconvex. --- numpy/linalg/linalg.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/numpy/linalg/linalg.py b/numpy/linalg/linalg.py index f1b2c2228684..6249a57c263a 100644 --- a/numpy/linalg/linalg.py +++ b/numpy/linalg/linalg.py @@ -2355,7 +2355,7 @@ def norm(x, ord=None, axis=None, keepdims=False): Notes ----- - For values of ``ord <= 0``, the result is, strictly speaking, not a + For values of ``ord < 1``, the result is, strictly speaking, not a mathematical 'norm', but it may still be useful for various numerical purposes. From f6a7a440669c6f386a1b15e081c6db740bb87a88 Mon Sep 17 00:00:00 2001 From: Ralf Gommers Date: Fri, 6 Dec 2019 11:03:03 -0800 Subject: [PATCH 0027/4713] Revert "DEP: issue deprecation warning when creating ragged array (NEP 34)" --- doc/release/upcoming_changes/template.rst | 1 - numpy/core/src/multiarray/ctors.c | 28 +++-------- numpy/core/tests/test_deprecations.py | 10 ---- numpy/core/tests/test_multiarray.py | 50 +++++-------------- numpy/core/tests/test_numeric.py | 2 +- numpy/core/tests/test_regression.py | 11 ++-- numpy/core/tests/test_ufunc.py | 8 +-- numpy/lib/tests/test_arraypad.py | 33 ++++++------ numpy/lib/tests/test_io.py | 2 +- numpy/ma/core.py | 4 +- numpy/ma/tests/test_core.py | 2 +- .../test_generator_mt19937_regressions.py | 7 ++- .../tests/test_randomstate_regression.py | 5 +- numpy/random/tests/test_regression.py | 5 +- 14 files changed, 51 insertions(+), 117 deletions(-) diff --git a/doc/release/upcoming_changes/template.rst b/doc/release/upcoming_changes/template.rst index 997b4850ea58..9c8a3b5fca7e 100644 --- a/doc/release/upcoming_changes/template.rst +++ b/doc/release/upcoming_changes/template.rst @@ -17,7 +17,6 @@ {% if definitions[category]['showcontent'] %} {% for text, values in sections[section][category].items() %} {{ text }} - {{ get_indent(text) }}({{values|join(', ') }}) {% endfor %} diff --git a/numpy/core/src/multiarray/ctors.c b/numpy/core/src/multiarray/ctors.c index c69782cb64b9..7276add75bbe 100644 --- a/numpy/core/src/multiarray/ctors.c +++ b/numpy/core/src/multiarray/ctors.c @@ -688,12 +688,6 @@ discover_itemsize(PyObject *s, int nd, int *itemsize, int string_type) return 0; } -typedef enum { - DISCOVERED_OK = 0, - DISCOVERED_RAGGED = 1, - DISCOVERED_OBJECT = 2 -} discovered_t; - /* * Take an arbitrary object and discover how many dimensions it * has, filling in the dimensions as we go. @@ -701,7 +695,7 @@ typedef enum { static int discover_dimensions(PyObject *obj, int *maxndim, npy_intp *d, int check_it, int stop_at_string, int stop_at_tuple, - discovered_t *out_is_object) + int *out_is_object) { PyObject *e; npy_intp n, i; @@ -887,7 +881,7 @@ discover_dimensions(PyObject *obj, int *maxndim, npy_intp *d, int check_it, if (PyErr_ExceptionMatches(PyExc_KeyError)) { PyErr_Clear(); *maxndim = 0; - *out_is_object = DISCOVERED_OBJECT; + *out_is_object = 1; return 0; } else { @@ -946,7 +940,7 @@ discover_dimensions(PyObject *obj, int *maxndim, npy_intp *d, int check_it, *maxndim = all_elems_maxndim + 1; if (!all_dimensions_match) { /* typically results in an array containing variable-length lists */ - *out_is_object = DISCOVERED_RAGGED; + *out_is_object = 1; } } @@ -1755,7 +1749,7 @@ PyArray_GetArrayParamsFromObject(PyObject *op, /* Try to treat op as a list of lists */ if (!writeable && PySequence_Check(op)) { - int check_it, stop_at_string, stop_at_tuple; + int check_it, stop_at_string, stop_at_tuple, is_object; int type_num, type; /* @@ -1805,7 +1799,7 @@ PyArray_GetArrayParamsFromObject(PyObject *op, ((*out_dtype)->names || (*out_dtype)->subarray)); *out_ndim = NPY_MAXDIMS; - discovered_t is_object = DISCOVERED_OK; + is_object = 0; if (discover_dimensions( op, out_ndim, out_dims, check_it, stop_at_string, stop_at_tuple, &is_object) < 0) { @@ -1822,17 +1816,7 @@ PyArray_GetArrayParamsFromObject(PyObject *op, return 0; } /* If object arrays are forced */ - if (is_object != DISCOVERED_OK) { - if (is_object == DISCOVERED_RAGGED && requested_dtype == NULL) { - /* NumPy 1.18, 2019-11-01 */ - if (DEPRECATE("Creating an ndarray with automatic object " - "dtype is deprecated, use dtype=object if you intended " - "it, otherwise specify an exact dtype") < 0) - { - return -1; - } - } - /* either DISCOVERED_OBJECT or there is a requested_dtype */ + if (is_object) { Py_DECREF(*out_dtype); *out_dtype = PyArray_DescrFromType(NPY_OBJECT); if (*out_dtype == NULL) { diff --git a/numpy/core/tests/test_deprecations.py b/numpy/core/tests/test_deprecations.py index de1d7685765b..363ff26db320 100644 --- a/numpy/core/tests/test_deprecations.py +++ b/numpy/core/tests/test_deprecations.py @@ -568,13 +568,3 @@ class TestNonZero(_DeprecationTestCase): def test_zerod(self): self.assert_deprecated(lambda: np.nonzero(np.array(0))) self.assert_deprecated(lambda: np.nonzero(np.array(1))) - - -class TestRaggedArray(_DeprecationTestCase): - # 2019-11-29 1.18.0 - def test_deprecate_ragged_arrays(self): - # NEP 34 deprecated automatic object dtype when creating ragged - # arrays. Also see the "ragged" tests in `test_multiarray` - arg = [1, [2, 3]] - self.assert_deprecated(np.array, args=(arg,)) - diff --git a/numpy/core/tests/test_multiarray.py b/numpy/core/tests/test_multiarray.py index 0235c5063604..22d550eccbe0 100644 --- a/numpy/core/tests/test_multiarray.py +++ b/numpy/core/tests/test_multiarray.py @@ -448,7 +448,7 @@ def test_array(self): assert_equal(r, np.ones((2, 6, 6))) d = np.ones((6, )) - r = np.array([[d, d + 1], d + 2], dtype=object) + r = np.array([[d, d + 1], d + 2]) assert_equal(len(r), 2) assert_equal(r[0], [d, d + 1]) assert_equal(r[1], d + 2) @@ -1051,60 +1051,34 @@ def test_array_too_big(self): assert_raises(ValueError, np.ndarray, buffer=buf, strides=(0,), shape=(max_bytes//itemsize + 1,), dtype=dtype) - def _ragged_creation(self, seq): - # without dtype=object, the ragged object should raise - with assert_warns(DeprecationWarning): - a = np.array(seq) - b = np.array(seq, dtype=object) - assert_equal(a, b) - return b - - def test_ragged_ndim_object(self): + def test_jagged_ndim_object(self): # Lists of mismatching depths are treated as object arrays - a = self._ragged_creation([[1], 2, 3]) + a = np.array([[1], 2, 3]) assert_equal(a.shape, (3,)) assert_equal(a.dtype, object) - a = self._ragged_creation([1, [2], 3]) + a = np.array([1, [2], 3]) assert_equal(a.shape, (3,)) assert_equal(a.dtype, object) - a = self._ragged_creation([1, 2, [3]]) + a = np.array([1, 2, [3]]) assert_equal(a.shape, (3,)) assert_equal(a.dtype, object) - def test_ragged_shape_object(self): + def test_jagged_shape_object(self): # The jagged dimension of a list is turned into an object array - a = self._ragged_creation([[1, 1], [2], [3]]) + a = np.array([[1, 1], [2], [3]]) + assert_equal(a.shape, (3,)) + assert_equal(a.dtype, object) + + a = np.array([[1], [2, 2], [3]]) assert_equal(a.shape, (3,)) assert_equal(a.dtype, object) - a = self._ragged_creation([[1], [2, 2], [3]]) + a = np.array([[1], [2], [3, 3]]) assert_equal(a.shape, (3,)) assert_equal(a.dtype, object) - a = self._ragged_creation([[1], [2], [3, 3]]) - assert a.shape == (3,) - assert a.dtype == object - - def test_array_of_ragged_array(self): - outer = np.array([None, None]) - outer[0] = outer[1] = np.array([1, 2, 3]) - assert np.array(outer).shape == (2,) - assert np.array([outer]).shape == (1, 2) - - outer_ragged = np.array([None, None]) - outer_ragged[0] = np.array([1, 2, 3]) - outer_ragged[1] = np.array([1, 2, 3, 4]) - # should both of these emit deprecation warnings? - assert np.array(outer_ragged).shape == (2,) - assert np.array([outer_ragged]).shape == (1, 2,) - - def test_deep_nonragged_object(self): - # None of these should raise, even though they are missing dtype=object - a = np.array([[[Decimal(1)]]]) - a = np.array([1, Decimal(1)]) - a = np.array([[1], [Decimal(1)]]) class TestStructured(object): def test_subarray_field_access(self): diff --git a/numpy/core/tests/test_numeric.py b/numpy/core/tests/test_numeric.py index 1f8c7e98dda5..ffebdf64870c 100644 --- a/numpy/core/tests/test_numeric.py +++ b/numpy/core/tests/test_numeric.py @@ -1211,7 +1211,7 @@ def test_array_method(self): def test_nonzero_invalid_object(self): # gh-9295 - a = np.array([np.array([1, 2]), 3], dtype=object) + a = np.array([np.array([1, 2]), 3]) assert_raises(ValueError, np.nonzero, a) class BoolErrors: diff --git a/numpy/core/tests/test_regression.py b/numpy/core/tests/test_regression.py index f3e170470183..3880b139418a 100644 --- a/numpy/core/tests/test_regression.py +++ b/numpy/core/tests/test_regression.py @@ -1367,13 +1367,13 @@ def test_fromiter_bytes(self): def test_array_from_sequence_scalar_array(self): # Ticket #1078: segfaults when creating an array with a sequence of # 0d arrays. - a = np.array((np.ones(2), np.array(2)), dtype=object) + a = np.array((np.ones(2), np.array(2))) assert_equal(a.shape, (2,)) assert_equal(a.dtype, np.dtype(object)) assert_equal(a[0], np.ones(2)) assert_equal(a[1], np.array(2)) - a = np.array(((1,), np.array(1)), dtype=object) + a = np.array(((1,), np.array(1))) assert_equal(a.shape, (2,)) assert_equal(a.dtype, np.dtype(object)) assert_equal(a[0], (1,)) @@ -1381,7 +1381,7 @@ def test_array_from_sequence_scalar_array(self): def test_array_from_sequence_scalar_array2(self): # Ticket #1081: weird array with strange input... - t = np.array([np.array([]), np.array(0, object)], dtype=object) + t = np.array([np.array([]), np.array(0, object)]) assert_equal(t.shape, (2,)) assert_equal(t.dtype, np.dtype(object)) @@ -2290,10 +2290,9 @@ def f(x): x[0], x[-1] = x[-1], x[0] uf = np.frompyfunc(f, 1, 0) - a = np.array([[1, 2, 3], [4, 5], [6, 7, 8, 9]], dtype=object) + a = np.array([[1, 2, 3], [4, 5], [6, 7, 8, 9]]) assert_equal(uf(a), ()) - expected = np.array([[3, 2, 1], [5, 4], [9, 7, 8, 6]], dtype=object) - assert_array_equal(a, expected) + assert_array_equal(a, [[3, 2, 1], [5, 4], [9, 7, 8, 6]]) @pytest.mark.skipif(not HAS_REFCOUNT, reason="Python lacks refcounts") def test_leak_in_structured_dtype_comparison(self): diff --git a/numpy/core/tests/test_ufunc.py b/numpy/core/tests/test_ufunc.py index e629945fa385..7109de77685c 100644 --- a/numpy/core/tests/test_ufunc.py +++ b/numpy/core/tests/test_ufunc.py @@ -1162,18 +1162,14 @@ def test_object_array_accumulate_inplace(self): # Twice reproduced also for tuples: np.add.accumulate(arr, out=arr) np.add.accumulate(arr, out=arr) - assert_array_equal(arr, - np.array([[1]*i for i in [1, 3, 6, 10]], dtype=object), - ) + assert_array_equal(arr, np.array([[1]*i for i in [1, 3, 6, 10]])) # And the same if the axis argument is used arr = np.ones((2, 4), dtype=object) arr[0, :] = [[2] for i in range(4)] np.add.accumulate(arr, out=arr, axis=-1) np.add.accumulate(arr, out=arr, axis=-1) - assert_array_equal(arr[0, :], - np.array([[2]*i for i in [1, 3, 6, 10]], dtype=object), - ) + assert_array_equal(arr[0, :], np.array([[2]*i for i in [1, 3, 6, 10]])) def test_object_array_reduceat_inplace(self): # Checks that in-place reduceats work, see also gh-7465 diff --git a/numpy/lib/tests/test_arraypad.py b/numpy/lib/tests/test_arraypad.py index 1c3507a62814..65593dd29922 100644 --- a/numpy/lib/tests/test_arraypad.py +++ b/numpy/lib/tests/test_arraypad.py @@ -1262,29 +1262,24 @@ def test_negative_pad_width(self, pad_width, mode): with pytest.raises(ValueError, match=match): np.pad(arr, pad_width, mode) - @pytest.mark.parametrize("pad_width, dtype", [ - ("3", None), - ("word", None), - (None, None), - (object(), None), - (3.4, None), - (((2, 3, 4), (3, 2)), object), - (complex(1, -1), None), - (((-2.1, 3), (3, 2)), None), + @pytest.mark.parametrize("pad_width", [ + "3", + "word", + None, + object(), + 3.4, + ((2, 3, 4), (3, 2)), # dtype=object (tuple) + complex(1, -1), + ((-2.1, 3), (3, 2)), ]) @pytest.mark.parametrize("mode", _all_modes.keys()) - def test_bad_type(self, pad_width, dtype, mode): + def test_bad_type(self, pad_width, mode): arr = np.arange(30).reshape((6, 5)) match = "`pad_width` must be of integral type." - if dtype is not None: - # avoid DeprecationWarning when not specifying dtype - with pytest.raises(TypeError, match=match): - np.pad(arr, np.array(pad_width, dtype=dtype), mode) - else: - with pytest.raises(TypeError, match=match): - np.pad(arr, pad_width, mode) - with pytest.raises(TypeError, match=match): - np.pad(arr, np.array(pad_width), mode) + with pytest.raises(TypeError, match=match): + np.pad(arr, pad_width, mode) + with pytest.raises(TypeError, match=match): + np.pad(arr, np.array(pad_width), mode) def test_pad_width_as_ndarray(self): a = np.arange(12) diff --git a/numpy/lib/tests/test_io.py b/numpy/lib/tests/test_io.py index 39fe40685943..a095e250af05 100644 --- a/numpy/lib/tests/test_io.py +++ b/numpy/lib/tests/test_io.py @@ -580,7 +580,7 @@ def test_unicode_and_bytes_fmt(self, fmt, iotype): def test_large_zip(self): # The test takes at least 6GB of memory, writes a file larger than 4GB test_data = np.asarray([np.random.rand(np.random.randint(50,100),4) - for i in range(800000)], dtype=object) + for i in range(800000)]) with tempdir() as tmpdir: np.savez(os.path.join(tmpdir, 'test.npz'), test_data=test_data) diff --git a/numpy/ma/core.py b/numpy/ma/core.py index 5aced840aeac..2baf547a423a 100644 --- a/numpy/ma/core.py +++ b/numpy/ma/core.py @@ -2828,8 +2828,8 @@ def __new__(cls, data=None, mask=nomask, dtype=None, copy=False, elif isinstance(data, (tuple, list)): try: # If data is a sequence of masked array - mask = np.array([getmaskarray(np.asanyarray(m, dtype=mdtype)) - for m in data], dtype=mdtype) + mask = np.array([getmaskarray(m) for m in data], + dtype=mdtype) except ValueError: # If data is nested mask = nomask diff --git a/numpy/ma/tests/test_core.py b/numpy/ma/tests/test_core.py index 3f7226dfb32b..b72ce56aa299 100644 --- a/numpy/ma/tests/test_core.py +++ b/numpy/ma/tests/test_core.py @@ -936,7 +936,7 @@ def test_mvoid_multidim_print(self): def test_object_with_array(self): mx1 = masked_array([1.], mask=[True]) mx2 = masked_array([1., 2.]) - mx = masked_array([mx1, mx2], mask=[False, True], dtype=object) + mx = masked_array([mx1, mx2], mask=[False, True]) assert_(mx[0] is mx1) assert_(mx[1] is not mx2) assert_(np.all(mx[1].data == mx2.data)) diff --git a/numpy/random/tests/test_generator_mt19937_regressions.py b/numpy/random/tests/test_generator_mt19937_regressions.py index e328c0c713b4..3a937f997a43 100644 --- a/numpy/random/tests/test_generator_mt19937_regressions.py +++ b/numpy/random/tests/test_generator_mt19937_regressions.py @@ -56,10 +56,9 @@ def test_shuffle_mixed_dimension(self): [1, (2, 2), (3, 3), None], [(1, 1), 2, 3, None]]: mt19937 = Generator(MT19937(12345)) - shuffled = np.array(t, dtype=object) + shuffled = list(t) mt19937.shuffle(shuffled) - expected = np.array([t[2], t[0], t[3], t[1]], dtype=object) - assert_array_equal(np.array(shuffled, dtype=object), expected) + assert_array_equal(shuffled, [t[2], t[0], t[3], t[1]]) def test_call_within_randomstate(self): # Check that custom BitGenerator does not call into global state @@ -119,7 +118,7 @@ def test_shuffle_of_array_of_objects(self): # a segfault on garbage collection. # See gh-7719 mt19937 = Generator(MT19937(1234)) - a = np.array([np.arange(1), np.arange(4)], dtype=object) + a = np.array([np.arange(1), np.arange(4)]) for _ in range(1000): mt19937.shuffle(a) diff --git a/numpy/random/tests/test_randomstate_regression.py b/numpy/random/tests/test_randomstate_regression.py index 827240cefad2..bdc2214b6ee5 100644 --- a/numpy/random/tests/test_randomstate_regression.py +++ b/numpy/random/tests/test_randomstate_regression.py @@ -68,8 +68,7 @@ def test_shuffle_mixed_dimension(self): random.seed(12345) shuffled = list(t) random.shuffle(shuffled) - expected = np.array([t[0], t[3], t[1], t[2]], dtype=object) - assert_array_equal(np.array(shuffled, dtype=object), expected) + assert_array_equal(shuffled, [t[0], t[3], t[1], t[2]]) def test_call_within_randomstate(self): # Check that custom RandomState does not call into global state @@ -129,7 +128,7 @@ def test_shuffle_of_array_of_objects(self): # a segfault on garbage collection. # See gh-7719 random.seed(1234) - a = np.array([np.arange(1), np.arange(4)], dtype=object) + a = np.array([np.arange(1), np.arange(4)]) for _ in range(1000): random.shuffle(a) diff --git a/numpy/random/tests/test_regression.py b/numpy/random/tests/test_regression.py index 3cc289a806c6..509e2d57ff28 100644 --- a/numpy/random/tests/test_regression.py +++ b/numpy/random/tests/test_regression.py @@ -66,8 +66,7 @@ def test_shuffle_mixed_dimension(self): np.random.seed(12345) shuffled = list(t) random.shuffle(shuffled) - expected = np.array([t[0], t[3], t[1], t[2]], dtype=object) - assert_array_equal(np.array(shuffled, dtype=object), expected) + assert_array_equal(shuffled, [t[0], t[3], t[1], t[2]]) def test_call_within_randomstate(self): # Check that custom RandomState does not call into global state @@ -127,7 +126,7 @@ def test_shuffle_of_array_of_objects(self): # a segfault on garbage collection. # See gh-7719 np.random.seed(1234) - a = np.array([np.arange(1), np.arange(4)], dtype=object) + a = np.array([np.arange(1), np.arange(4)]) for _ in range(1000): np.random.shuffle(a) From 95e570ca1de9a59e1fe478057c5921bbd6dd5f70 Mon Sep 17 00:00:00 2001 From: Daniel Povey Date: Sat, 7 Dec 2019 05:23:37 +0800 Subject: [PATCH 0028/4713] DOC: clarify documentation for transpose() (gh-15024) Clarify axes argument and general text of `np.transpose`. --- numpy/core/fromnumeric.py | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/numpy/core/fromnumeric.py b/numpy/core/fromnumeric.py index d454480a8b47..286b0699e528 100644 --- a/numpy/core/fromnumeric.py +++ b/numpy/core/fromnumeric.py @@ -604,15 +604,20 @@ def _transpose_dispatcher(a, axes=None): @array_function_dispatch(_transpose_dispatcher) def transpose(a, axes=None): """ - Permute the dimensions of an array. + Reverse or permute the axes of an array; returns the modified array. + + For an array a with two axes, transpose(a) gives the matrix transpose. Parameters ---------- a : array_like Input array. - axes : list of ints, optional - By default, reverse the dimensions, otherwise permute the axes - according to the values given. + axes : tuple or list of ints, optional + If specified, it must be a tuple or list which contains a permutation of + [0,1,..,N-1] where N is the number of axes of a. The i'th axis of the + returned array will correspond to the axis numbered ``axes[i]`` of the + input. If not specified, defaults to ``range(a.ndim)[::-1]``, which + reverses the order of the axes. Returns ------- @@ -797,7 +802,7 @@ def argpartition(a, kth, axis=-1, kind='introselect', order=None): partition : Describes partition algorithms used. ndarray.partition : Inplace partition. argsort : Full indirect sort. - take_along_axis : Apply ``index_array`` from argpartition + take_along_axis : Apply ``index_array`` from argpartition to an array as if by calling partition. Notes @@ -1039,7 +1044,7 @@ def argsort(a, axis=-1, kind=None, order=None): lexsort : Indirect stable sort with multiple keys. ndarray.sort : Inplace sort. argpartition : Indirect partial sort. - take_along_axis : Apply ``index_array`` from argsort + take_along_axis : Apply ``index_array`` from argsort to an array as if by calling sort. Notes @@ -1136,7 +1141,7 @@ def argmax(a, axis=None, out=None): ndarray.argmax, argmin amax : The maximum value along a given axis. unravel_index : Convert a flat index into an index tuple. - take_along_axis : Apply ``np.expand_dims(index_array, axis)`` + take_along_axis : Apply ``np.expand_dims(index_array, axis)`` from argmax to an array as if by calling max. Notes @@ -1217,7 +1222,7 @@ def argmin(a, axis=None, out=None): ndarray.argmin, argmax amin : The minimum value along a given axis. unravel_index : Convert a flat index into an index tuple. - take_along_axis : Apply ``np.expand_dims(index_array, axis)`` + take_along_axis : Apply ``np.expand_dims(index_array, axis)`` from argmin to an array as if by calling min. Notes From 96eab839e721cfa0b11213c74dd80f14b2560179 Mon Sep 17 00:00:00 2001 From: Tyler Reddy Date: Sat, 7 Dec 2019 06:58:53 -0700 Subject: [PATCH 0029/4713] DOC: correct version for NaT sort * NaT sorting to the end of arrays was adjusted in NumPy 1.18.0 instead of 1.17.0, so adjust sort() docs accordingly --- numpy/core/fromnumeric.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/numpy/core/fromnumeric.py b/numpy/core/fromnumeric.py index 286b0699e528..f09f2a465d0e 100644 --- a/numpy/core/fromnumeric.py +++ b/numpy/core/fromnumeric.py @@ -949,7 +949,7 @@ def sort(a, axis=-1, kind=None, order=None): 'mergesort' and 'stable' are mapped to radix sort for integer data types. Radix sort is an O(n) sort instead of O(n log n). - .. versionchanged:: 1.17.0 + .. versionchanged:: 1.18.0 NaT now sorts to the end of arrays for consistency with NaN. From 98c14a085cece71f54910cd11c39fe7a193d6022 Mon Sep 17 00:00:00 2001 From: Warren Weckesser Date: Sun, 8 Dec 2019 00:18:45 -0500 Subject: [PATCH 0030/4713] MAINT: core: Fix a very long line in generated ufunc docstrings. Put the $BROADCASTABLE_2 text on its own line, and add a line break in the text. This changes a typical ufunc docstring from this (note the very long line beginning 'The arrays to be subtracted...'): ``` Parameters ---------- x1, x2 : array_like The arrays to be subtracted from each other. If ``x1.shape != x2.shape``, they must be broadcastable to a common shape (which becomes the shape of the output). out : ndarray, None, or tuple of ndarray and None, optional A location into which the result is stored. If provided, it must have ``` to this: ``` Parameters ---------- x1, x2 : array_like The arrays to be subtracted from each other. If ``x1.shape != x2.shape``, they must be broadcastable to a common shape (which becomes the shape of the output). out : ndarray, None, or tuple of ndarray and None, optional A location into which the result is stored. If provided, it must have ``` --- .../core/code_generators/ufunc_docstrings.py | 112 ++++++++++++------ 1 file changed, 74 insertions(+), 38 deletions(-) diff --git a/numpy/core/code_generators/ufunc_docstrings.py b/numpy/core/code_generators/ufunc_docstrings.py index 4dec73505ab3..dfa20f221305 100644 --- a/numpy/core/code_generators/ufunc_docstrings.py +++ b/numpy/core/code_generators/ufunc_docstrings.py @@ -37,8 +37,8 @@ def get(name): :ref:`ufunc docs `. """).strip(), 'BROADCASTABLE_2': ("If ``x1.shape != x2.shape``, they must be " - "broadcastable to a common shape (which becomes the " - "shape of the output)."), + "broadcastable to a common\n shape (which becomes " + "the shape of the output)."), 'OUT_SCALAR_1': "This is a scalar if `x` is a scalar.", 'OUT_SCALAR_2': "This is a scalar if both `x1` and `x2` are scalars.", } @@ -117,7 +117,8 @@ def add_newdoc(place, name, doc): Parameters ---------- x1, x2 : array_like - The arrays to be added. $BROADCASTABLE_2 + The arrays to be added. + $BROADCASTABLE_2 $PARAMS Returns @@ -443,7 +444,8 @@ def add_newdoc(place, name, doc): x1 : array_like, real-valued `y`-coordinates. x2 : array_like, real-valued - `x`-coordinates. $BROADCASTABLE_2 + `x`-coordinates. + $BROADCASTABLE_2 $PARAMS Returns @@ -566,7 +568,8 @@ def add_newdoc(place, name, doc): Parameters ---------- x1, x2 : array_like - Only integer and boolean types are handled. $BROADCASTABLE_2 + Only integer and boolean types are handled. + $BROADCASTABLE_2 $PARAMS Returns @@ -619,7 +622,8 @@ def add_newdoc(place, name, doc): Parameters ---------- x1, x2 : array_like - Only integer and boolean types are handled. $BROADCASTABLE_2 + Only integer and boolean types are handled. + $BROADCASTABLE_2 $PARAMS Returns @@ -677,7 +681,8 @@ def add_newdoc(place, name, doc): Parameters ---------- x1, x2 : array_like - Only integer and boolean types are handled. $BROADCASTABLE_2 + Only integer and boolean types are handled. + $BROADCASTABLE_2 $PARAMS Returns @@ -987,7 +992,8 @@ def add_newdoc(place, name, doc): x1 : array_like Input values. x2 : array_like - The value of the function when x1 is 0. $BROADCASTABLE_2 + The value of the function when x1 is 0. + $BROADCASTABLE_2 $PARAMS Returns @@ -1022,7 +1028,8 @@ def add_newdoc(place, name, doc): x1 : array_like Dividend array. x2 : array_like - Divisor array. $BROADCASTABLE_2 + Divisor array. + $BROADCASTABLE_2 $PARAMS Returns @@ -1091,7 +1098,8 @@ def add_newdoc(place, name, doc): Parameters ---------- x1, x2 : array_like - Input arrays. $BROADCASTABLE_2 + Input arrays. + $BROADCASTABLE_2 $PARAMS Returns @@ -1338,7 +1346,8 @@ def add_newdoc(place, name, doc): x1 : array_like Numerator. x2 : array_like - Denominator. $BROADCASTABLE_2 + Denominator. + $BROADCASTABLE_2 $PARAMS Returns @@ -1378,7 +1387,8 @@ def add_newdoc(place, name, doc): x1 : array_like Dividend. x2 : array_like - Divisor. $BROADCASTABLE_2 + Divisor. + $BROADCASTABLE_2 $PARAMS Returns @@ -1428,7 +1438,8 @@ def add_newdoc(place, name, doc): Parameters ---------- x1, x2 : array_like - Input arrays. $BROADCASTABLE_2 + Input arrays. + $BROADCASTABLE_2 $PARAMS Returns @@ -1464,7 +1475,8 @@ def add_newdoc(place, name, doc): Parameters ---------- x1, x2 : array_like - Input arrays. $BROADCASTABLE_2 + Input arrays. + $BROADCASTABLE_2 $PARAMS Returns @@ -1497,7 +1509,8 @@ def add_newdoc(place, name, doc): Parameters ---------- x1, x2 : array_like - Leg of the triangle(s). $BROADCASTABLE_2 + Leg of the triangle(s). + $BROADCASTABLE_2 $PARAMS Returns @@ -1832,7 +1845,8 @@ def add_newdoc(place, name, doc): Parameters ---------- x1, x2 : array_like - Input arrays. $BROADCASTABLE_2 + Input arrays. + $BROADCASTABLE_2 $PARAMS Returns @@ -1860,7 +1874,8 @@ def add_newdoc(place, name, doc): Parameters ---------- x1, x2 : array_like - Input arrays. $BROADCASTABLE_2 + Input arrays. + $BROADCASTABLE_2 $PARAMS Returns @@ -2044,7 +2059,8 @@ def add_newdoc(place, name, doc): Parameters ---------- x1, x2 : array_like - Input values. $BROADCASTABLE_2 + Input values. + $BROADCASTABLE_2 $PARAMS Returns @@ -2086,7 +2102,8 @@ def add_newdoc(place, name, doc): Parameters ---------- x1, x2 : array_like - Input values. $BROADCASTABLE_2 + Input values. + $BROADCASTABLE_2 $PARAMS Returns @@ -2177,7 +2194,8 @@ def add_newdoc(place, name, doc): Parameters ---------- x1, x2 : array_like - Input arrays. $BROADCASTABLE_2 + Input arrays. + $BROADCASTABLE_2 $PARAMS Returns @@ -2282,7 +2300,8 @@ def add_newdoc(place, name, doc): Parameters ---------- x1, x2 : array_like - Logical XOR is applied to the elements of `x1` and `x2`. $BROADCASTABLE_2 + Logical XOR is applied to the elements of `x1` and `x2`. + $BROADCASTABLE_2 $PARAMS Returns @@ -2329,7 +2348,8 @@ def add_newdoc(place, name, doc): Parameters ---------- x1, x2 : array_like - The arrays holding the elements to be compared. $BROADCASTABLE_2 + The arrays holding the elements to be compared. + $BROADCASTABLE_2 $PARAMS Returns @@ -2387,7 +2407,8 @@ def add_newdoc(place, name, doc): Parameters ---------- x1, x2 : array_like - The arrays holding the elements to be compared. $BROADCASTABLE_2 + The arrays holding the elements to be compared. + $BROADCASTABLE_2 $PARAMS Returns @@ -2445,7 +2466,8 @@ def add_newdoc(place, name, doc): Parameters ---------- x1, x2 : array_like - The arrays holding the elements to be compared. $BROADCASTABLE_2 + The arrays holding the elements to be compared. + $BROADCASTABLE_2 $PARAMS Returns @@ -2502,7 +2524,8 @@ def add_newdoc(place, name, doc): Parameters ---------- x1, x2 : array_like - The arrays holding the elements to be compared. $BROADCASTABLE_2 + The arrays holding the elements to be compared. + $BROADCASTABLE_2 $PARAMS Returns @@ -2755,7 +2778,8 @@ def add_newdoc(place, name, doc): Parameters ---------- x1, x2 : array_like - Input arrays to be multiplied. $BROADCASTABLE_2 + Input arrays to be multiplied. + $BROADCASTABLE_2 $PARAMS Returns @@ -2836,7 +2860,8 @@ def add_newdoc(place, name, doc): Parameters ---------- x1, x2 : array_like - Input arrays. $BROADCASTABLE_2 + Input arrays. + $BROADCASTABLE_2 $PARAMS Returns @@ -2885,7 +2910,8 @@ def add_newdoc(place, name, doc): x1 : array_like The bases. x2 : array_like - The exponents. $BROADCASTABLE_2 + The exponents. + $BROADCASTABLE_2 $PARAMS Returns @@ -2944,7 +2970,8 @@ def add_newdoc(place, name, doc): x1 : array_like The bases. x2 : array_like - The exponents. $BROADCASTABLE_2 + The exponents. + $BROADCASTABLE_2 $PARAMS Returns @@ -3116,7 +3143,8 @@ def add_newdoc(place, name, doc): x1 : array_like Dividend array. x2 : array_like - Divisor array. $BROADCASTABLE_2 + Divisor array. + $BROADCASTABLE_2 $PARAMS Returns @@ -3162,7 +3190,8 @@ def add_newdoc(place, name, doc): x1 : array_like Dividend array. x2 : array_like - Divisor array. $BROADCASTABLE_2 + Divisor array. + $BROADCASTABLE_2 $PARAMS Returns @@ -3201,7 +3230,8 @@ def add_newdoc(place, name, doc): x1 : array_like, int Input values. x2 : array_like, int - Number of bits to remove at the right of `x1`. $BROADCASTABLE_2 + Number of bits to remove at the right of `x1`. + $BROADCASTABLE_2 $PARAMS Returns @@ -3335,7 +3365,8 @@ def add_newdoc(place, name, doc): x1 : array_like Values to change the sign of. x2 : array_like - The sign of `x2` is copied to `x1`. $BROADCASTABLE_2 + The sign of `x2` is copied to `x1`. + $BROADCASTABLE_2 $PARAMS Returns @@ -3642,7 +3673,8 @@ def add_newdoc(place, name, doc): Parameters ---------- x1, x2 : array_like - The arrays to be subtracted from each other. $BROADCASTABLE_2 + The arrays to be subtracted from each other. + $BROADCASTABLE_2 $PARAMS Returns @@ -3783,7 +3815,8 @@ def add_newdoc(place, name, doc): x1 : array_like Dividend array. x2 : array_like - Divisor array. $BROADCASTABLE_2 + Divisor array. + $BROADCASTABLE_2 $PARAMS Returns @@ -3880,7 +3913,8 @@ def add_newdoc(place, name, doc): x1 : array_like Array of multipliers. x2 : array_like, int - Array of twos exponents. $BROADCASTABLE_2 + Array of twos exponents. + $BROADCASTABLE_2 $PARAMS Returns @@ -3918,7 +3952,8 @@ def add_newdoc(place, name, doc): Parameters ---------- x1, x2 : array_like, int - Arrays of values. $BROADCASTABLE_2 + Arrays of values. + $BROADCASTABLE_2 Returns ------- @@ -3948,7 +3983,8 @@ def add_newdoc(place, name, doc): Parameters ---------- x1, x2 : array_like, int - Arrays of values. $BROADCASTABLE_2 + Arrays of values. + $BROADCASTABLE_2 Returns ------- From c1c97173ae6ccf53a0ebc89c6b76fa62ab0fa5c8 Mon Sep 17 00:00:00 2001 From: Warren Weckesser Date: Sun, 8 Dec 2019 00:21:19 -0500 Subject: [PATCH 0031/4713] MAINT: core: Fix spacing in the expm1 docstring. --- numpy/core/code_generators/ufunc_docstrings.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/numpy/core/code_generators/ufunc_docstrings.py b/numpy/core/code_generators/ufunc_docstrings.py index dfa20f221305..9560eb31b38a 100644 --- a/numpy/core/code_generators/ufunc_docstrings.py +++ b/numpy/core/code_generators/ufunc_docstrings.py @@ -1231,7 +1231,7 @@ def add_newdoc(place, name, doc): Parameters ---------- x : array_like - Input values. + Input values. $PARAMS Returns From 3f845cee31a385c187f1a5637f06e3b4587f2691 Mon Sep 17 00:00:00 2001 From: Pauli Virtanen Date: Sat, 7 Dec 2019 23:15:21 +0200 Subject: [PATCH 0032/4713] TST: testing: check requires_memory immediately before the test + ignore MemoryErrors --- numpy/testing/_private/utils.py | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/numpy/testing/_private/utils.py b/numpy/testing/_private/utils.py index 32bd738bc3f0..8599222d394d 100644 --- a/numpy/testing/_private/utils.py +++ b/numpy/testing/_private/utils.py @@ -2388,6 +2388,29 @@ def requires_memory(free_bytes): """Decorator to skip a test if not enough memory is available""" import pytest + def decorator(func): + @wraps(func) + def wrapper(*a, **kw): + msg = check_free_memory(free_bytes) + if msg is not None: + pytest.skip(msg) + + try: + return func(*a, **kw) + except MemoryError: + # Probably ran out of memory regardless: don't regard as failure + pytest.xfail("MemoryError raised") + + return wrapper + + return decorator + + +def check_free_memory(free_bytes): + """ + Check whether `free_bytes` amount of memory is currently free. + Returns: None if enough memory available, otherwise error message + """ env_var = 'NPY_AVAILABLE_MEM' env_value = os.environ.get(env_var) if env_value is not None: @@ -2412,7 +2435,7 @@ def requires_memory(free_bytes): msg = '{0} GB memory required, but {1} GB available'.format( free_bytes/1e9, mem_free/1e9) - return pytest.mark.skipif(mem_free < free_bytes, reason=msg) + return msg if mem_free < free_bytes else None def _parse_size(size_str): From 7914ad1763b066ff7cc42d00f7eecaf5b49011e7 Mon Sep 17 00:00:00 2001 From: mattip Date: Tue, 10 Dec 2019 09:46:41 +0200 Subject: [PATCH 0033/4713] TST: add value to pytest.ini for pytest6 compatibility --- pytest.ini | 1 + 1 file changed, 1 insertion(+) diff --git a/pytest.ini b/pytest.ini index 4748e3575a29..74faefd6e7ee 100644 --- a/pytest.ini +++ b/pytest.ini @@ -2,6 +2,7 @@ addopts = -l norecursedirs = doc tools numpy/linalg/lapack_lite numpy/core/code_generators doctest_optionflags = NORMALIZE_WHITESPACE ELLIPSIS ALLOW_UNICODE ALLOW_BYTES +junit_family=xunit2 filterwarnings = error From 3261532917b3c3026aa9a3002d58b5915d7f315a Mon Sep 17 00:00:00 2001 From: Matti Picus Date: Wed, 11 Dec 2019 20:02:51 +0200 Subject: [PATCH 0034/4713] BUG: pickle the content of a scalar containing objects, not the address (gh-14940) Scalars with a void dtype that contains objects were not pickled properly. Add a test and fix by checking the NPY_LIST_PICKLE flag of the dtype. Fixes gh-13593 --- numpy/core/src/multiarray/multiarraymodule.c | 11 ++++++++- numpy/core/src/multiarray/scalartypes.c.src | 26 ++++++++++++++++++-- numpy/core/tests/test_records.py | 18 +++++++++++++- 3 files changed, 51 insertions(+), 4 deletions(-) diff --git a/numpy/core/src/multiarray/multiarraymodule.c b/numpy/core/src/multiarray/multiarraymodule.c index 9169814c24fc..33b654729fa0 100644 --- a/numpy/core/src/multiarray/multiarraymodule.c +++ b/numpy/core/src/multiarray/multiarraymodule.c @@ -1891,8 +1891,17 @@ array_scalar(PyObject *NPY_UNUSED(ignored), PyObject *args, PyObject *kwds) &PyArrayDescr_Type, &typecode, &obj)) { return NULL; } + if (PyDataType_FLAGCHK(typecode, NPY_LIST_PICKLE)) { + if (!PySequence_Check(obj)) { + PyErr_SetString(PyExc_TypeError, + "found non-sequence while unpickling scalar with " + "NPY_LIST_PICKLE set"); + return NULL; + } + dptr = &obj; + } - if (PyDataType_FLAGCHK(typecode, NPY_ITEM_IS_POINTER)) { + else if (PyDataType_FLAGCHK(typecode, NPY_ITEM_IS_POINTER)) { if (obj == NULL) { obj = Py_None; } diff --git a/numpy/core/src/multiarray/scalartypes.c.src b/numpy/core/src/multiarray/scalartypes.c.src index 5da7f7738673..91ee64b5f112 100644 --- a/numpy/core/src/multiarray/scalartypes.c.src +++ b/numpy/core/src/multiarray/scalartypes.c.src @@ -1884,8 +1884,30 @@ gentype_reduce(PyObject *self, PyObject *NPY_UNUSED(args)) PyTuple_SET_ITEM(ret, 0, obj); obj = PyObject_GetAttrString((PyObject *)self, "dtype"); if (PyArray_IsScalar(self, Object)) { - mod = ((PyObjectScalarObject *)self)->obval; - PyTuple_SET_ITEM(ret, 1, Py_BuildValue("NO", obj, mod)); + PyObject *val = ((PyObjectScalarObject *)self)->obval; + PyObject *tup = Py_BuildValue("NO", obj, val); + if (tup == NULL) { + return NULL; + } + PyTuple_SET_ITEM(ret, 1, tup); + } + else if (obj && PyDataType_FLAGCHK((PyArray_Descr *)obj, NPY_LIST_PICKLE)) { + /* a structured dtype with an object in a field */ + PyArrayObject *arr = (PyArrayObject *)PyArray_FromScalar(self, NULL); + if (arr == NULL) { + return NULL; + } + /* arr.item() */ + PyObject *val = PyArray_GETITEM(arr, PyArray_DATA(arr)); + Py_DECREF(arr); + if (val == NULL) { + return NULL; + } + PyObject *tup = Py_BuildValue("NN", obj, val); + if (tup == NULL) { + return NULL; + } + PyTuple_SET_ITEM(ret, 1, tup); } else { #ifndef Py_UNICODE_WIDE diff --git a/numpy/core/tests/test_records.py b/numpy/core/tests/test_records.py index c1b794145d19..0f88f99e0f68 100644 --- a/numpy/core/tests/test_records.py +++ b/numpy/core/tests/test_records.py @@ -15,7 +15,7 @@ from numpy.compat import Path from numpy.testing import ( assert_, assert_equal, assert_array_equal, assert_array_almost_equal, - assert_raises, temppath + assert_raises, temppath, ) from numpy.compat import pickle @@ -416,6 +416,22 @@ def test_pickle_3(self): assert_(pa.flags.writeable) assert_(pa.flags.aligned) + def test_pickle_void(self): + # issue gh-13593 + dt = np.dtype([('obj', 'O'), ('int', 'i')]) + a = np.empty(1, dtype=dt) + data = (bytearray(b'eman'),) + a['obj'] = data + a['int'] = 42 + ctor, args = a[0].__reduce__() + # check the contructor is what we expect before interpreting the arguments + assert ctor is np.core.multiarray.scalar + dtype, obj = args + # make sure we did not pickle the address + assert not isinstance(obj, bytes) + + assert_raises(TypeError, ctor, dtype, 13) + def test_objview_record(self): # https://github.com/numpy/numpy/issues/2599 dt = np.dtype([('foo', 'i8'), ('bar', 'O')]) From 578f4e7dca4701637284c782d8c74c0d5b688341 Mon Sep 17 00:00:00 2001 From: Tirth Patel Date: Thu, 12 Dec 2019 00:09:27 +0530 Subject: [PATCH 0035/4713] ENH: Add support to sort timedelta64 `NaT` to end of the array (gh-15068) This work is a follow up of gh-12658. As requested in gh-15063, add NaT sort support for timedelta64 datatypes also. Fixes gh-15063 --- doc/source/release/1.18.0-notes.rst | 1 + numpy/core/src/npysort/npysort_common.h | 8 +++++ numpy/core/tests/test_datetime.py | 42 ++++++++++++++++--------- 3 files changed, 36 insertions(+), 15 deletions(-) diff --git a/doc/source/release/1.18.0-notes.rst b/doc/source/release/1.18.0-notes.rst index 0cea811fb88b..76b358d98a86 100644 --- a/doc/source/release/1.18.0-notes.rst +++ b/doc/source/release/1.18.0-notes.rst @@ -296,6 +296,7 @@ Changes purposes, so that it sorts to the end of arrays. This change is for consistency with ``NaN`` sorting behavior. (`gh-12658 `__) +(`gh-15068 `__) Incorrect ``threshold`` in ``np.set_printoptions`` raises ``TypeError`` or ``ValueError`` ----------------------------------------------------------------------------------------- diff --git a/numpy/core/src/npysort/npysort_common.h b/numpy/core/src/npysort/npysort_common.h index 30c0d47f3a49..2a6e4d421234 100644 --- a/numpy/core/src/npysort/npysort_common.h +++ b/numpy/core/src/npysort/npysort_common.h @@ -344,6 +344,14 @@ DATETIME_LT(npy_datetime a, npy_datetime b) NPY_INLINE static int TIMEDELTA_LT(npy_timedelta a, npy_timedelta b) { + if (a == NPY_DATETIME_NAT) { + return 0; + } + + if (b == NPY_DATETIME_NAT) { + return 1; + } + return a < b; } diff --git a/numpy/core/tests/test_datetime.py b/numpy/core/tests/test_datetime.py index 41b84a69fd6d..d38444ef7ea1 100644 --- a/numpy/core/tests/test_datetime.py +++ b/numpy/core/tests/test_datetime.py @@ -145,35 +145,47 @@ def test_compare_generic_nat(self): assert_(np.datetime64('NaT') != np.datetime64('NaT', 'us')) assert_(np.datetime64('NaT', 'us') != np.datetime64('NaT')) - - @pytest.mark.parametrize("size", [ 3, 21, 217, 1000]) - def test_nat_argsort_stability(self, size): + def test_datetime_nat_argsort_stability(self, size): # NaT < NaT should be False internally for # sort stability expected = np.arange(size) arr = np.tile(np.datetime64('NaT'), size) assert_equal(np.argsort(arr, kind='mergesort'), expected) + + @pytest.mark.parametrize("size", [ + 3, 21, 217, 1000]) + def test_timedelta_nat_argsort_stability(self, size): + # NaT < NaT should be False internally for + # sort stability + expected = np.arange(size) + arr = np.tile(np.timedelta64('NaT'), size) + assert_equal(np.argsort(arr, kind='mergesort'), expected) @pytest.mark.parametrize("arr, expected", [ # the example provided in gh-12629 - (np.array(['NaT', 1, 2, 3], dtype='M8[ns]'), - np.array([1, 2, 3, 'NaT'], dtype='M8[ns]')), + (['NaT', 1, 2, 3], + [1, 2, 3, 'NaT']), # multiple NaTs - (np.array(['NaT', 9, 'NaT', -707], dtype='M8[s]'), - np.array([-707, 9, 'NaT', 'NaT'], dtype='M8[s]')), + (['NaT', 9, 'NaT', -707], + [-707, 9, 'NaT', 'NaT']), # this sort explores another code path for NaT - (np.array([1, -2, 3, 'NaT'], dtype='M8[ns]'), - np.array([-2, 1, 3, 'NaT'], dtype='M8[ns]')), + ([1, -2, 3, 'NaT'], + [-2, 1, 3, 'NaT']), # 2-D array - (np.array([[51, -220, 'NaT'], - [-17, 'NaT', -90]], dtype='M8[us]'), - np.array([[-220, 51, 'NaT'], - [-90, -17, 'NaT']], dtype='M8[us]')), + ([[51, -220, 'NaT'], + [-17, 'NaT', -90]], + [[-220, 51, 'NaT'], + [-90, -17, 'NaT']]), ]) - def test_sort_nat(self, arr, expected): - # fix for gh-12629; NaT sorting to end of array + @pytest.mark.parametrize("dtype", [ + 'M8[ns]', 'M8[us]', + 'm8[ns]', 'm8[us]']) + def test_datetime_timedelta_sort_nat(self, arr, expected, dtype): + # fix for gh-12629 and gh-15063; NaT sorting to end of array + arr = np.array(arr, dtype=dtype) + expected = np.array(expected, dtype=dtype) arr.sort() assert_equal(arr, expected) From 2fc10a279edfd132ec27eeac9e72f5a02a8bae5e Mon Sep 17 00:00:00 2001 From: Matti Picus Date: Sat, 14 Dec 2019 08:22:31 +0200 Subject: [PATCH 0036/4713] DOC: bring the out parameter docstring into line with ufuncs (#15097) --- numpy/lib/ufunclike.py | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/numpy/lib/ufunclike.py b/numpy/lib/ufunclike.py index 96fd5b319a00..9f03b13291c6 100644 --- a/numpy/lib/ufunclike.py +++ b/numpy/lib/ufunclike.py @@ -85,13 +85,20 @@ def fix(x, out=None): ---------- x : array_like An array of floats to be rounded - y : ndarray, optional - Output array + out : ndarray, optional + A location into which the result is stored. If provided, it must have + a shape that the input broadcasts to. If not provided or None, a + freshly-allocated array is returned. Returns ------- out : ndarray of floats - The array of rounded numbers + A float array with the same dimensions as the input. + If second argument is not supplied then a float array is returned + with the rounded values. + + If a second argument is supplied the result is stored there. + The return value `out` is then a reference to that array. See Also -------- @@ -129,8 +136,10 @@ def isposinf(x, out=None): ---------- x : array_like The input array. - y : array_like, optional - A boolean array with the same shape as `x` to store the result. + out : array_like, optional + A location into which the result is stored. If provided, it must have a + shape that the input broadcasts to. If not provided or None, a + freshly-allocated boolean array is returned. Returns ------- @@ -199,8 +208,9 @@ def isneginf(x, out=None): x : array_like The input array. out : array_like, optional - A boolean array with the same shape and type as `x` to store the - result. + A location into which the result is stored. If provided, it must have a + shape that the input broadcasts to. If not provided or None, a + freshly-allocated boolean array is returned. Returns ------- From a92039db1edf9d85059ddadc10134f434ae82ce7 Mon Sep 17 00:00:00 2001 From: Pauli Virtanen Date: Sat, 7 Dec 2019 14:17:20 +0200 Subject: [PATCH 0037/4713] ENH: distutils: add support for ILP64 OpenBLAS (generic symbol suffix) Generalize the ILP64 BLAS/LAPACK symbol name handling to deal with arbitrary prefix/suffix. The build-time behavior is changed so that HAVE_BLAS_ILP64 and BLAS_SYMBOL_SUFFIX/PREFIX defines are added to compile options as appropriate. Mainly to make autodetection of BLAS/LAPACK easier for downstream numpy.distutils users, add get_info aliases 'blas_ilp64_opt', 'blas_ilp64_plain_opt', and 'blas64__opt' for any/no/""&"64_" prefix&suffix, and the same for lapack. (Due to the way system_info works, each also gets a separate class.) In addition to openblas64_ which has a fixed suffix, add the (by default suffixless) openblas_ilp64, which correspond to the most likely cases to be present. --- numpy/core/setup.py | 11 +-- numpy/distutils/system_info.py | 163 +++++++++++++++++++++++++-------- numpy/linalg/setup.py | 6 +- site.cfg.example | 25 ++++- 4 files changed, 155 insertions(+), 50 deletions(-) diff --git a/numpy/core/setup.py b/numpy/core/setup.py index 5bbb1c62223d..974ec4628c72 100644 --- a/numpy/core/setup.py +++ b/numpy/core/setup.py @@ -91,9 +91,6 @@ def is_npy_no_smp(): # block. return 'NPY_NOSMP' in os.environ -def is_npy_use_blas64_(): - return (os.environ.get('NPY_USE_BLAS64_', "0") != "0") - def win32_checks(deflist): from numpy.distutils.misc_util import get_build_architecture a = get_build_architecture() @@ -756,12 +753,12 @@ def get_mathlib_info(*args): join('src', 'common', 'numpyos.c'), ] - if is_npy_use_blas64_(): - blas_info = get_info('blas64__opt', 2) - have_blas = blas_info and ('HAVE_CBLAS64_', None) in blas_info.get('define_macros', []) + if os.environ.get('NPY_USE_BLAS_ILP64', "0") != "0": + blas_info = get_info('blas_ilp64_opt', 2) else: blas_info = get_info('blas_opt', 0) - have_blas = blas_info and ('HAVE_CBLAS', None) in blas_info.get('define_macros', []) + + have_blas = blas_info and ('HAVE_CBLAS', None) in blas_info.get('define_macros', []) if have_blas: extra_info = blas_info diff --git a/numpy/distutils/system_info.py b/numpy/distutils/system_info.py index fc2902b78287..4786b3a0cc93 100644 --- a/numpy/distutils/system_info.py +++ b/numpy/distutils/system_info.py @@ -22,11 +22,16 @@ lapack_info openblas_info openblas64__info + openblas_ilp64_info blis_info blas_opt_info # usage recommended lapack_opt_info # usage recommended - blas64__opt_info # usage recommended - lapack64__opt_info # usage recommended + blas_ilp64_opt_info # usage recommended (general ILP64 BLAS) + lapack_ilp64_opt_info # usage recommended (general ILP64 LAPACK) + blas_ilp64_plain_opt_info # usage recommended (general ILP64 BLAS, no symbol suffix) + lapack_ilp64_plain_opt_info # usage recommended (general ILP64 LAPACK, no symbol suffix) + blas64__opt_info # usage recommended (general ILP64 BLAS, 64_ symbol suffix) + lapack64__opt_info # usage recommended (general ILP64 LAPACK, 64_ symbol suffix) fftw_info,dfftw_info,sfftw_info fftw_threads_info,dfftw_threads_info,sfftw_threads_info djbfft_info @@ -411,6 +416,8 @@ def get_info(name, notfound_action=0): 'accelerate': accelerate_info, # use blas_opt instead 'openblas64_': openblas64__info, 'openblas64__lapack': openblas64__lapack_info, + 'openblas_ilp64': openblas_ilp64_info, + 'openblas_ilp64_lapack': openblas_ilp64_lapack_info, 'x11': x11_info, 'fft_opt': fft_opt_info, 'fftw': fftw_info, @@ -433,8 +440,12 @@ def get_info(name, notfound_action=0): 'numarray': numarray_info, 'numerix': numerix_info, 'lapack_opt': lapack_opt_info, + 'lapack_ilp64_opt': lapack_ilp64_opt_info, + 'lapack_ilp64_plain_opt': lapack_ilp64_plain_opt_info, 'lapack64__opt': lapack64__opt_info, 'blas_opt': blas_opt_info, + 'blas_ilp64_opt': blas_ilp64_opt_info, + 'blas_ilp64_plain_opt': blas_ilp64_plain_opt_info, 'blas64__opt': blas64__opt_info, 'boost_python': boost_python_info, 'agg2': agg2_info, @@ -501,14 +512,13 @@ class LapackSrcNotFoundError(LapackNotFoundError): the LAPACK_SRC environment variable.""" -class Lapack64_NotFoundError(NotFoundError): +class LapackILP64NotFoundError(NotFoundError): """ - 64-bit Lapack libraries with '64_' symbol suffix not found. + 64-bit Lapack libraries not found. Known libraries in numpy/distutils/site.cfg file are: - openblas64_ + openblas64_, openblas_ilp64 """ - class BlasOptNotFoundError(NotFoundError): """ Optimized (vendor) Blas libraries are not found. @@ -523,11 +533,11 @@ class BlasNotFoundError(NotFoundError): numpy/distutils/site.cfg file (section [blas]) or by setting the BLAS environment variable.""" -class Blas64_NotFoundError(NotFoundError): +class BlasILP64NotFoundError(NotFoundError): """ - 64-bit Blas libraries with '64_' symbol suffix not found. + 64-bit Blas libraries not found. Known libraries in numpy/distutils/site.cfg file are: - openblas64_ + openblas64_, openblas_ilp64 """ class BlasSrcNotFoundError(BlasNotFoundError): @@ -1716,6 +1726,9 @@ def _calc_info_lapack(self): return True return False + def _calc_info(self, name): + return getattr(self, '_calc_info_{}'.format(name))() + def calc_info(self): user_order = os.environ.get(self.order_env_var_name, None) if user_order is None: @@ -1737,7 +1750,7 @@ def calc_info(self): "values: {}".format(non_existing)) for lapack in lapack_order: - if getattr(self, '_calc_info_{}'.format(lapack))(): + if self._calc_info(lapack): return if 'lapack' not in lapack_order: @@ -1746,19 +1759,49 @@ def calc_info(self): warnings.warn(LapackNotFoundError.__doc__ or '', stacklevel=2) warnings.warn(LapackSrcNotFoundError.__doc__ or '', stacklevel=2) -class lapack64__opt_info(lapack_opt_info): - notfounderror = Lapack64_NotFoundError - lapack_order = ['openblas64_'] - order_env_var_name = 'NPY_LAPACK64__ORDER' - def _calc_info_openblas64_(self): - info = get_info('openblas64__lapack') - if info: +class _ilp64_opt_info_mixin: + symbol_suffix = None + symbol_prefix = None + + def _check_info(self, info): + macros = dict(info.get('define_macros', [])) + prefix = macros.get('BLAS_SYMBOL_PREFIX', '') + suffix = macros.get('BLAS_SYMBOL_SUFFIX', '') + + if self.symbol_prefix not in (None, prefix): + return False + + if self.symbol_suffix not in (None, suffix): + return False + + return bool(info) + + +class lapack_ilp64_opt_info(lapack_opt_info, _ilp64_opt_info_mixin): + notfounderror = LapackILP64NotFoundError + lapack_order = ['openblas64_', 'openblas_ilp64'] + order_env_var_name = 'NPY_LAPACK_ILP64_ORDER' + + def _calc_info(self, name): + info = get_info(name + '_lapack') + if self._check_info(info): self.set_info(**info) return True return False +class lapack_ilp64_plain_opt_info(lapack_ilp64_opt_info): + # Same as lapack_ilp64_opt_info, but fix symbol names + symbol_prefix = '' + symbol_suffix = '' + + +class lapack64__opt_info(lapack_ilp64_opt_info): + symbol_prefix = '' + symbol_suffix = '64_' + + class blas_opt_info(system_info): notfounderror = BlasNotFoundError # List of all known BLAS libraries, in the default order @@ -1828,6 +1871,9 @@ def _calc_info_blas(self): self.set_info(**info) return True + def _calc_info(self, name): + return getattr(self, '_calc_info_{}'.format(name))() + def calc_info(self): user_order = os.environ.get(self.order_env_var_name, None) if user_order is None: @@ -1847,7 +1893,7 @@ def calc_info(self): raise ValueError("blas_opt_info user defined BLAS order has unacceptable values: {}".format(non_existing)) for blas in blas_order: - if getattr(self, '_calc_info_{}'.format(blas))(): + if self._calc_info(blas): return if 'blas' not in blas_order: @@ -1857,19 +1903,29 @@ def calc_info(self): warnings.warn(BlasSrcNotFoundError.__doc__ or '', stacklevel=2) -class blas64__opt_info(blas_opt_info): - notfounderror = Blas64_NotFoundError - blas_order = ['openblas64_'] - order_env_var_name = 'NPY_BLAS64__ORDER' +class blas_ilp64_opt_info(blas_opt_info, _ilp64_opt_info_mixin): + notfounderror = BlasILP64NotFoundError + blas_order = ['openblas64_', 'openblas_ilp64'] + order_env_var_name = 'NPY_BLAS_ILP64_ORDER' - def _calc_info_openblas64_(self): - info = get_info('openblas64_') - if info: + def _calc_info(self, name): + info = get_info(name) + if self._check_info(info): self.set_info(**info) return True return False +class blas_ilp64_plain_opt_info(blas_ilp64_opt_info): + symbol_prefix = '' + symbol_suffix = '' + + +class blas64__opt_info(blas_ilp64_opt_info): + symbol_prefix = '' + symbol_suffix = '64_' + + class blas_info(system_info): section = 'blas' dir_env_var = 'BLAS' @@ -1972,6 +2028,20 @@ class openblas_info(blas_info): _require_symbols = [] notfounderror = BlasNotFoundError + @property + def symbol_prefix(self): + try: + return self.cp.get(self.section, 'symbol_prefix') + except NoOptionError: + return '' + + @property + def symbol_suffix(self): + try: + return self.cp.get(self.section, 'symbol_suffix') + except NoOptionError: + return '' + def _calc_info(self): c = customized_ccompiler() @@ -2006,6 +2076,10 @@ def _calc_info(self): return None info['define_macros'] = [('HAVE_CBLAS', None)] + if self.symbol_prefix: + info['define_macros'] += [('BLAS_SYMBOL_PREFIX', self.symbol_prefix)] + if self.symbol_suffix: + info['define_macros'] += [('BLAS_SYMBOL_SUFFIX', self.symbol_suffix)] return info @@ -2051,9 +2125,13 @@ def check_symbols(self, info): tmpdir = tempfile.mkdtemp() - prototypes = "\n".join("void %s();" % symbol_name + prototypes = "\n".join("void %s%s%s();" % (self.symbol_prefix, + symbol_name, + self.symbol_suffix) for symbol_name in self._require_symbols) - calls = "\n".join("%s();" % symbol_name + calls = "\n".join("%s%s%s();" % (self.symbol_prefix, + symbol_name, + self.symbol_suffix) for symbol_name in self._require_symbols) s = textwrap.dedent("""\ %(prototypes)s @@ -2096,28 +2174,39 @@ class openblas_lapack_info(openblas_info): class openblas_clapack_info(openblas_lapack_info): _lib_names = ['openblas', 'lapack'] -class openblas64__info(openblas_info): - section = 'openblas64_' - dir_env_var = 'OPENBLAS64_' - _lib_names = ['openblas64_'] - _require_symbols = ['dgemm_64_', 'cblas_dgemm64_'] - notfounderror = Blas64_NotFoundError +class openblas_ilp64_info(openblas_info): + section = 'openblas_ilp64' + dir_env_var = 'OPENBLAS_ILP64' + _lib_names = ['openblas64'] + _require_symbols = ['dgemm_', 'cblas_dgemm'] + notfounderror = BlasILP64NotFoundError def _calc_info(self): info = super()._calc_info() if info is not None: - info['define_macros'] = [('HAVE_CBLAS64_', None)] + info['define_macros'] += [('HAVE_BLAS_ILP64', None)] return info -class openblas64__lapack_info(openblas64__info): - _require_symbols = ['dgemm_64_', 'cblas_dgemm64_', 'zungqr_64_', 'LAPACKE_zungqr64_'] +class openblas_ilp64_lapack_info(openblas_ilp64_info): + _require_symbols = ['dgemm_', 'cblas_dgemm', 'zungqr_', 'LAPACKE_zungqr'] def _calc_info(self): info = super()._calc_info() if info: - info['define_macros'] += [('HAVE_LAPACKE64_', None)] + info['define_macros'] += [('HAVE_LAPACKE', None)] return info +class openblas64__info(openblas_ilp64_info): + # ILP64 Openblas, with default symbol suffix + section = 'openblas64_' + dir_env_var = 'OPENBLAS64_' + _lib_names = ['openblas64_'] + symbol_suffix = '64_' + symbol_prefix = '' + +class openblas64__lapack_info(openblas_ilp64_lapack_info, openblas64__info): + pass + class blis_info(blas_info): section = 'blis' dir_env_var = 'BLIS' diff --git a/numpy/linalg/setup.py b/numpy/linalg/setup.py index f5cb04e891a2..6315a34b41d0 100644 --- a/numpy/linalg/setup.py +++ b/numpy/linalg/setup.py @@ -26,10 +26,8 @@ def configuration(parent_package='', top_path=None): ] all_sources = config.paths(lapack_lite_src) - if (os.environ.get('NPY_USE_BLAS64_', "0") != "0"): - lapack_info = get_info('lapack64__opt', 2) - lapack_info.setdefault('define_macros', []) - lapack_info['define_macros'] += [('NPY_UMATH_USE_BLAS64_', None)] + if os.environ.get('NPY_USE_BLAS_ILP64', "0") != "0": + lapack_info = get_info('lapack_ilp64_opt', 2) else: lapack_info = get_info('lapack_opt', 0) # and {} diff --git a/site.cfg.example b/site.cfg.example index a58039df373a..ba912866a4bd 100644 --- a/site.cfg.example +++ b/site.cfg.example @@ -140,8 +140,9 @@ # This is an emerging "standard" for 64-bit BLAS/LAPACK, avoiding symbol clashes # with 32-bit BLAS/LAPACK. # -# To build Numpy with such 64-bit BLAS/LAPACK, set environment variable -# NPY_USE_BLAS64_=1 at build time. +# To build Numpy with such 64-bit BLAS/LAPACK, set environment +# variables NPY_USE_BLAS_ILP64=1, NPY_BLAS_ILP64_ORDER=openblas64_, +# NPY_LAPACK_ILP64_ORDER=openblas64_ at build time. # # See: # https://github.com/xianyi/OpenBLAS/issues/646 @@ -152,6 +153,26 @@ # include_dirs = /opt/OpenBLAS/include # runtime_library_dirs = /opt/OpenBLAS/lib +# OpenBLAS (64-bit ILP64) +# ----------------------- +# It is possible to also use OpenBLAS compiled with 64-bit integer +# size (ILP64) but no symbol name changes. To do that, set the +# environment variables NPY_USE_BLAS_ILP64=1, +# NPY_BLAS_ILP64_ORDER=openblas_ilp64, +# NPY_LAPACK_ILP64_ORDER=openblas_ilp64 at build time. +# +# Note that mixing both 64-bit and 32-bit BLAS without symbol suffixes +# in the same application may cause problems due to symbol name +# clashes, especially with embedded Python interpreters. +# +# [openblas_ilp64] +# libraries = openblas64 +# library_dirs = /opt/OpenBLAS/lib +# include_dirs = /opt/OpenBLAS/include +# runtime_library_dirs = /opt/OpenBLAS/lib +# symbol_prefix = +# symbol_suffix = + # BLIS # ---- # BLIS (https://github.com/flame/blis) also provides a BLAS interface. It's a From 669cd13c692cfe8476e24dad3d42bbbd94547727 Mon Sep 17 00:00:00 2001 From: Pauli Virtanen Date: Sat, 7 Dec 2019 14:40:48 +0200 Subject: [PATCH 0038/4713] ENH: update BLAS symbol suffix/prefix handling in cblasfuncs & linalg Revise the BLAS name mangling to support the general scheme. --- numpy/core/src/common/cblasfuncs.c | 10 -------- numpy/core/src/common/npy_cblas.h | 30 +++++++++++++++++++++-- numpy/core/src/common/npy_cblas64_.h | 31 ------------------------ numpy/core/src/common/python_xerbla.c | 19 +++------------ numpy/linalg/lapack_lite/python_xerbla.c | 13 +++------- numpy/linalg/lapack_litemodule.c | 27 +++++---------------- numpy/linalg/umath_linalg.c.src | 20 +++------------ numpy/testing/_private/utils.py | 2 +- 8 files changed, 45 insertions(+), 107 deletions(-) delete mode 100644 numpy/core/src/common/npy_cblas64_.h diff --git a/numpy/core/src/common/cblasfuncs.c b/numpy/core/src/common/cblasfuncs.c index 14d13a6c7eed..e78587de06d8 100644 --- a/numpy/core/src/common/cblasfuncs.c +++ b/numpy/core/src/common/cblasfuncs.c @@ -10,20 +10,10 @@ #include #include #include "npy_cblas.h" -#include "npy_cblas64_.h" #include "arraytypes.h" #include "common.h" -/* - * If 64-bit CBLAS with symbol suffix '64_' is available, use it. - */ -#ifdef HAVE_CBLAS64_ -#define CBLAS_FUNC(name) name ## 64_ -#else -#define CBLAS_FUNC(name) name -#endif - static const double oneD[2] = {1.0, 0.0}, zeroD[2] = {0.0, 0.0}; static const float oneF[2] = {1.0, 0.0}, zeroF[2] = {0.0, 0.0}; diff --git a/numpy/core/src/common/npy_cblas.h b/numpy/core/src/common/npy_cblas.h index 12db55bde6ab..97308238a23d 100644 --- a/numpy/core/src/common/npy_cblas.h +++ b/numpy/core/src/common/npy_cblas.h @@ -25,8 +25,34 @@ enum CBLAS_SIDE {CblasLeft=141, CblasRight=142}; #define CBLAS_INDEX size_t /* this may vary between platforms */ -#define BLASINT int -#define BLASNAME(name) name +#ifdef NO_APPEND_FORTRAN +#define BLAS_FORTRAN_SUFFIX +#else +#define BLAS_FORTRAN_SUFFIX _ +#endif + +#ifndef BLAS_SYMBOL_PREFIX +#define BLAS_SYMBOL_PREFIX +#endif + +#ifndef BLAS_SYMBOL_SUFFIX +#define BLAS_SYMBOL_SUFFIX +#endif + +#define BLAS_FUNC_CONCAT(name,prefix,suffix,suffix2) prefix ## name ## suffix ## suffix2 +#define BLAS_FUNC_EXPAND(name,prefix,suffix,suffix2) BLAS_FUNC_CONCAT(name,prefix,suffix,suffix2) + +#define CBLAS_FUNC(name) BLAS_FUNC_EXPAND(name,BLAS_SYMBOL_PREFIX,,BLAS_SYMBOL_SUFFIX) +#define BLAS_FUNC(name) BLAS_FUNC_EXPAND(name,BLAS_SYMBOL_PREFIX,BLAS_FORTRAN_SUFFIX,BLAS_SYMBOL_SUFFIX) + +#ifdef HAVE_BLAS_ILP64 +#define CBLAS_INT npy_int64 +#else +#define CBLAS_INT int +#endif + +#define BLASNAME(name) CBLAS_FUNC(name) +#define BLASINT CBLAS_INT #include "npy_cblas_base.h" diff --git a/numpy/core/src/common/npy_cblas64_.h b/numpy/core/src/common/npy_cblas64_.h deleted file mode 100644 index bbc4b3559de7..000000000000 --- a/numpy/core/src/common/npy_cblas64_.h +++ /dev/null @@ -1,31 +0,0 @@ -/* - * This header provides numpy a consistent interface to CBLAS code. It is needed - * because not all providers of cblas provide cblas.h. For instance, MKL provides - * mkl_cblas.h and also typedefs the CBLAS_XXX enums. - */ -#ifndef _NPY_CBLAS64__H_ -#define _NPY_CBLAS64__H_ - -#include - -#include "npy_cblas.h" - -/* Allow the use in C++ code. */ -#ifdef __cplusplus -extern "C" -{ -#endif - -#define BLASINT npy_int64 -#define BLASNAME(name) name##64_ - -#include "npy_cblas_base.h" - -#undef BLASINT -#undef BLASNAME - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/numpy/core/src/common/python_xerbla.c b/numpy/core/src/common/python_xerbla.c index d88562b7a0eb..fe2f718b2e58 100644 --- a/numpy/core/src/common/python_xerbla.c +++ b/numpy/core/src/common/python_xerbla.c @@ -1,11 +1,6 @@ #include "Python.h" #include "numpy/npy_common.h" - -/* - * From f2c.h, this should be safe unless fortran is set to use 64 - * bit integers. We don't seem to have any good way to detect that. - */ -typedef int integer; +#include "npy_cblas.h" /* From the original manpage: @@ -24,7 +19,7 @@ typedef int integer; info: Number of the invalid parameter. */ -int xerbla_(char *srname, integer *info) +CBLAS_INT BLAS_FUNC(xerbla)(char *srname, CBLAS_INT *info) { static const char format[] = "On entry to %.*s" \ " parameter number %d had an illegal value"; @@ -42,7 +37,7 @@ int xerbla_(char *srname, integer *info) #ifdef WITH_THREAD save = PyGILState_Ensure(); #endif - PyOS_snprintf(buf, sizeof(buf), format, len, srname, *info); + PyOS_snprintf(buf, sizeof(buf), format, len, srname, (int)*info); PyErr_SetString(PyExc_ValueError, buf); #ifdef WITH_THREAD PyGILState_Release(save); @@ -50,11 +45,3 @@ int xerbla_(char *srname, integer *info) return 0; } - - -/* Same for LAPACK64_ */ -npy_int64 xerbla_64_(char *srname, npy_int64 *info) -{ - integer info_int = (integer)*info; - return xerbla_(srname, &info_int); -} diff --git a/numpy/linalg/lapack_lite/python_xerbla.c b/numpy/linalg/lapack_lite/python_xerbla.c index c239a36202f4..4dbb92e1f455 100644 --- a/numpy/linalg/lapack_lite/python_xerbla.c +++ b/numpy/linalg/lapack_lite/python_xerbla.c @@ -1,5 +1,6 @@ #include "Python.h" #include "numpy/npy_common.h" +#include "npy_cblas.h" #undef c_abs #include "f2c.h" @@ -21,7 +22,7 @@ info: Number of the invalid parameter. */ -int xerbla_(char *srname, integer *info) +CBLAS_INT BLAS_FUNC(xerbla)(char *srname, CBLAS_INT *info) { static const char format[] = "On entry to %.*s" \ " parameter number %d had an illegal value"; @@ -39,7 +40,7 @@ int xerbla_(char *srname, integer *info) #ifdef WITH_THREAD save = PyGILState_Ensure(); #endif - PyOS_snprintf(buf, sizeof(buf), format, len, srname, *info); + PyOS_snprintf(buf, sizeof(buf), format, len, srname, (int)*info); PyErr_SetString(PyExc_ValueError, buf); #ifdef WITH_THREAD PyGILState_Release(save); @@ -47,11 +48,3 @@ int xerbla_(char *srname, integer *info) return 0; } - - -/* Same for LAPACK64_ */ -npy_int64 xerbla_64_(char *srname, npy_int64 *info) -{ - integer info_int = (integer)*info; - return xerbla_(srname, &info_int); -} diff --git a/numpy/linalg/lapack_litemodule.c b/numpy/linalg/lapack_litemodule.c index c80179fdf370..4c80317f556b 100644 --- a/numpy/linalg/lapack_litemodule.c +++ b/numpy/linalg/lapack_litemodule.c @@ -6,31 +6,14 @@ More modifications by Jeff Whitaker #include "Python.h" #include "numpy/arrayobject.h" +#include "npy_cblas.h" -#ifndef NPY_UMATH_USE_BLAS64_ - -/* - * Standard BLAS - */ -#ifdef NO_APPEND_FORTRAN -# define FNAME(x) x -#else -# define FNAME(x) x##_ -#endif +#define FNAME(name) BLAS_FUNC(name) -#define FINT_PYFMT "i" -typedef int fortran_int; +typedef CBLAS_INT fortran_int; -#else - -/* - * BLAS64_ - */ - -#define FNAME(x) x##_64_ - -typedef npy_int64 fortran_int; +#ifdef HAVE_BLAS_ILP64 #if NPY_BITSOF_SHORT == 64 #define FINT_PYFMT "h" @@ -46,6 +29,8 @@ typedef npy_int64 fortran_int; compiler and platform, or set NPY_USE_BLAS64_=0 #endif +#else +#define FINT_PYFMT "i" #endif typedef struct { float r, i; } f2c_complex; diff --git a/numpy/linalg/umath_linalg.c.src b/numpy/linalg/umath_linalg.c.src index b111f75d5644..e864c541b089 100644 --- a/numpy/linalg/umath_linalg.c.src +++ b/numpy/linalg/umath_linalg.c.src @@ -15,6 +15,8 @@ #include "npy_config.h" +#include "npy_cblas.h" + #include #include #include @@ -62,23 +64,9 @@ dbg_stack_trace() ***************************************************************************** */ -#ifndef NPY_UMATH_USE_BLAS64_ - -#ifdef NO_APPEND_FORTRAN -# define FNAME(x) x -#else -# define FNAME(x) x##_ -#endif - -typedef int fortran_int; +#define FNAME(x) BLAS_FUNC(x) -#else - -#define FNAME(x) x##_64_ - -typedef npy_int64 fortran_int; - -#endif +typedef CBLAS_INT fortran_int; typedef struct { float r, i; } f2c_complex; typedef struct { double r, i; } f2c_doublecomplex; diff --git a/numpy/testing/_private/utils.py b/numpy/testing/_private/utils.py index 8599222d394d..23267a9e1f72 100644 --- a/numpy/testing/_private/utils.py +++ b/numpy/testing/_private/utils.py @@ -54,7 +54,7 @@ class KnownFailureException(Exception): IS_PYPY = platform.python_implementation() == 'PyPy' HAS_REFCOUNT = getattr(sys, 'getrefcount', None) is not None -HAS_LAPACK64 = hasattr(numpy.__config__, 'lapack64__opt_info') +HAS_LAPACK64 = hasattr(numpy.__config__, 'lapack_ilp64_opt_info') def import_nose(): From b7f42ea0616812518e04e9e25d89476145c7552c Mon Sep 17 00:00:00 2001 From: Pauli Virtanen Date: Sat, 7 Dec 2019 23:48:29 +0200 Subject: [PATCH 0039/4713] DOC: document 64-bit BLAS/LAPACK build-time variables --- doc/source/user/building.rst | 40 ++++++++++++++++++++++++------------ 1 file changed, 27 insertions(+), 13 deletions(-) diff --git a/doc/source/user/building.rst b/doc/source/user/building.rst index 8e2b5c03b510..8e9744a877be 100644 --- a/doc/source/user/building.rst +++ b/doc/source/user/building.rst @@ -195,23 +195,37 @@ or:: BLAS=None LAPACK=None ATLAS=None python setup.py build -64-bit BLAS and LAPACK with symbol suffix -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +64-bit BLAS and LAPACK +~~~~~~~~~~~~~~~~~~~~~~ + +You can tell Numpy to use 64-bit BLAS/LAPACK libraries by setting the +environment variable:: + + NPY_USE_BLAS_ILP64=1 + +when building Numpy. The following 64-bit BLAS/LAPACK libraries are +supported: + +1. OpenBLAS ILP64 with ``64_`` symbol suffix (``openblas64_``) +2. OpenBLAS ILP64 without symbol suffix (``openblas_ilp64``) + +The order in which they are preferred is determined by +``NPY_BLAS_ILP64_ORDER`` and ``NPY_LAPACK_ILP64_ORDER`` environment +variables, similarly as above. + +.. note:: -Numpy also supports 64-bit OpenBLAS with ``64_`` symbol suffix. Such -library is obtained by compiling OpenBLAS with settings:: + Using non-symbol-suffixed 64-bit BLAS/LAPACK in a program that also + uses 32-bit BLAS/LAPACK can cause crashes under certain conditions + (e.g. with embedded Python interpreters on Linux). - make INTERFACE64=1 SYMBOLSUFFIX=64_ + The 64-bit OpenBLAS with ``64_`` symbol suffix is obtained by + compiling OpenBLAS with settings:: -To make Numpy use it, set ``NPY_USE_BLAS64_=1`` environment variable -when building Numpy. You may also need to configure the -``[openblas64_]`` section in ``site.cfg``. + make INTERFACE64=1 SYMBOLSUFFIX=64_ -The symbol suffix avoids symbol name clashes between 32-bit and 64-bit -BLAS/LAPACK libraries, meaning that you can link to both in the same -program. This avoids potential issues when using 64-bit BLAS/LAPACK in -Numpy while simultaneously using other Python software that uses the -32-bit versions. + The symbol suffix avoids the symbol name clashes between 32-bit and + 64-bit BLAS/LAPACK libraries. Supplying additional compiler flags From de8a10dc543f69e2111d250c79f1414b70a08686 Mon Sep 17 00:00:00 2001 From: Pauli Virtanen Date: Mon, 9 Dec 2019 20:47:28 +0200 Subject: [PATCH 0040/4713] BUG: core: use blas_ilp64 also for *_matmul, *_dot, and *_vdot Changing these to support ILP64 blas was missed in gh-15012 --- numpy/core/src/multiarray/arraytypes.c.src | 16 +++---- numpy/core/src/multiarray/common.h | 10 ++++- numpy/core/src/multiarray/vdot.c | 16 +++---- numpy/core/src/umath/matmul.c.src | 49 ++++++++++++---------- 4 files changed, 53 insertions(+), 38 deletions(-) diff --git a/numpy/core/src/multiarray/arraytypes.c.src b/numpy/core/src/multiarray/arraytypes.c.src index e36b95c00918..9e108e3e140a 100644 --- a/numpy/core/src/multiarray/arraytypes.c.src +++ b/numpy/core/src/multiarray/arraytypes.c.src @@ -3535,17 +3535,17 @@ NPY_NO_EXPORT void npy_intp n, void *NPY_UNUSED(ignore)) { #if defined(HAVE_CBLAS) - int is1b = blas_stride(is1, sizeof(@type@)); - int is2b = blas_stride(is2, sizeof(@type@)); + CBLAS_INT is1b = blas_stride(is1, sizeof(@type@)); + CBLAS_INT is2b = blas_stride(is2, sizeof(@type@)); if (is1b && is2b) { double sum = 0.; /* double for stability */ while (n > 0) { - int chunk = n < NPY_CBLAS_CHUNK ? n : NPY_CBLAS_CHUNK; + CBLAS_INT chunk = n < NPY_CBLAS_CHUNK ? n : NPY_CBLAS_CHUNK; - sum += cblas_@prefix@dot(chunk, + sum += CBLAS_FUNC(cblas_@prefix@dot)(chunk, (@type@ *) ip1, is1b, (@type@ *) ip2, is2b); /* use char strides here */ @@ -3584,17 +3584,17 @@ NPY_NO_EXPORT void char *op, npy_intp n, void *NPY_UNUSED(ignore)) { #if defined(HAVE_CBLAS) - int is1b = blas_stride(is1, sizeof(@ctype@)); - int is2b = blas_stride(is2, sizeof(@ctype@)); + CBLAS_INT is1b = blas_stride(is1, sizeof(@ctype@)); + CBLAS_INT is2b = blas_stride(is2, sizeof(@ctype@)); if (is1b && is2b) { double sum[2] = {0., 0.}; /* double for stability */ while (n > 0) { - int chunk = n < NPY_CBLAS_CHUNK ? n : NPY_CBLAS_CHUNK; + CBLAS_INT chunk = n < NPY_CBLAS_CHUNK ? n : NPY_CBLAS_CHUNK; @type@ tmp[2]; - cblas_@prefix@dotu_sub((int)n, ip1, is1b, ip2, is2b, tmp); + CBLAS_FUNC(cblas_@prefix@dotu_sub)((CBLAS_INT)n, ip1, is1b, ip2, is2b, tmp); sum[0] += (double)tmp[0]; sum[1] += (double)tmp[1]; /* use char strides here */ diff --git a/numpy/core/src/multiarray/common.h b/numpy/core/src/multiarray/common.h index 487d530a148b..7eee9ddc5db6 100644 --- a/numpy/core/src/multiarray/common.h +++ b/numpy/core/src/multiarray/common.h @@ -303,7 +303,11 @@ blas_stride(npy_intp stride, unsigned itemsize) */ if (stride > 0 && npy_is_aligned((void *)stride, itemsize)) { stride /= itemsize; +#ifndef HAVE_BLAS_ILP64 if (stride <= INT_MAX) { +#else + if (stride <= NPY_MAX_INT64) { +#endif return stride; } } @@ -314,7 +318,11 @@ blas_stride(npy_intp stride, unsigned itemsize) * Define a chunksize for CBLAS. CBLAS counts in integers. */ #if NPY_MAX_INTP > INT_MAX -# define NPY_CBLAS_CHUNK (INT_MAX / 2 + 1) +# ifndef HAVE_BLAS_ILP64 +# define NPY_CBLAS_CHUNK (INT_MAX / 2 + 1) +# else +# define NPY_CBLAS_CHUNK (NPY_MAX_INT64 / 2 + 1) +# endif #else # define NPY_CBLAS_CHUNK NPY_MAX_INTP #endif diff --git a/numpy/core/src/multiarray/vdot.c b/numpy/core/src/multiarray/vdot.c index 424a21710f25..9b5d19522029 100644 --- a/numpy/core/src/multiarray/vdot.c +++ b/numpy/core/src/multiarray/vdot.c @@ -15,17 +15,17 @@ CFLOAT_vdot(char *ip1, npy_intp is1, char *ip2, npy_intp is2, char *op, npy_intp n, void *NPY_UNUSED(ignore)) { #if defined(HAVE_CBLAS) - int is1b = blas_stride(is1, sizeof(npy_cfloat)); - int is2b = blas_stride(is2, sizeof(npy_cfloat)); + CBLAS_INT is1b = blas_stride(is1, sizeof(npy_cfloat)); + CBLAS_INT is2b = blas_stride(is2, sizeof(npy_cfloat)); if (is1b && is2b) { double sum[2] = {0., 0.}; /* double for stability */ while (n > 0) { - int chunk = n < NPY_CBLAS_CHUNK ? n : NPY_CBLAS_CHUNK; + CBLAS_INT chunk = n < NPY_CBLAS_CHUNK ? n : NPY_CBLAS_CHUNK; float tmp[2]; - cblas_cdotc_sub((int)n, ip1, is1b, ip2, is2b, tmp); + CBLAS_FUNC(cblas_cdotc_sub)((CBLAS_INT)n, ip1, is1b, ip2, is2b, tmp); sum[0] += (double)tmp[0]; sum[1] += (double)tmp[1]; /* use char strides here */ @@ -66,17 +66,17 @@ CDOUBLE_vdot(char *ip1, npy_intp is1, char *ip2, npy_intp is2, char *op, npy_intp n, void *NPY_UNUSED(ignore)) { #if defined(HAVE_CBLAS) - int is1b = blas_stride(is1, sizeof(npy_cdouble)); - int is2b = blas_stride(is2, sizeof(npy_cdouble)); + CBLAS_INT is1b = blas_stride(is1, sizeof(npy_cdouble)); + CBLAS_INT is2b = blas_stride(is2, sizeof(npy_cdouble)); if (is1b && is2b) { double sum[2] = {0., 0.}; /* double for stability */ while (n > 0) { - int chunk = n < NPY_CBLAS_CHUNK ? n : NPY_CBLAS_CHUNK; + CBLAS_INT chunk = n < NPY_CBLAS_CHUNK ? n : NPY_CBLAS_CHUNK; double tmp[2]; - cblas_zdotc_sub((int)n, ip1, is1b, ip2, is2b, tmp); + CBLAS_FUNC(cblas_zdotc_sub)((CBLAS_INT)n, ip1, is1b, ip2, is2b, tmp); sum[0] += (double)tmp[0]; sum[1] += (double)tmp[1]; /* use char strides here */ diff --git a/numpy/core/src/umath/matmul.c.src b/numpy/core/src/umath/matmul.c.src index b5204eca5747..c8f7c654dc17 100644 --- a/numpy/core/src/umath/matmul.c.src +++ b/numpy/core/src/umath/matmul.c.src @@ -31,7 +31,11 @@ * -1 to be conservative, in case blas internally uses a for loop with an * inclusive upper bound */ +#ifndef HAVE_BLAS_ILP64 #define BLAS_MAXSIZE (NPY_MAX_INT - 1) +#else +#define BLAS_MAXSIZE (NPY_MAX_INT64 - 1) +#endif /* * Determine if a 2d matrix can be used by BLAS @@ -84,25 +88,25 @@ NPY_NO_EXPORT void * op: data in c order, m shape */ enum CBLAS_ORDER order; - int M, N, lda; + CBLAS_INT M, N, lda; assert(m <= BLAS_MAXSIZE && n <= BLAS_MAXSIZE); assert (is_blasable2d(is2_n, sizeof(@typ@), n, 1, sizeof(@typ@))); - M = (int)m; - N = (int)n; + M = (CBLAS_INT)m; + N = (CBLAS_INT)n; if (is_blasable2d(is1_m, is1_n, m, n, sizeof(@typ@))) { order = CblasColMajor; - lda = (int)(is1_m / sizeof(@typ@)); + lda = (CBLAS_INT)(is1_m / sizeof(@typ@)); } else { /* If not ColMajor, caller should have ensured we are RowMajor */ /* will not assert in release mode */ order = CblasRowMajor; assert(is_blasable2d(is1_n, is1_m, n, m, sizeof(@typ@))); - lda = (int)(is1_n / sizeof(@typ@)); + lda = (CBLAS_INT)(is1_n / sizeof(@typ@)); } - cblas_@prefix@gemv(order, CblasTrans, N, M, @step1@, ip1, lda, ip2, + CBLAS_FUNC(cblas_@prefix@gemv)(order, CblasTrans, N, M, @step1@, ip1, lda, ip2, is2_n / sizeof(@typ@), @step0@, op, op_m / sizeof(@typ@)); } @@ -117,37 +121,37 @@ NPY_NO_EXPORT void */ enum CBLAS_ORDER order = CblasRowMajor; enum CBLAS_TRANSPOSE trans1, trans2; - int M, N, P, lda, ldb, ldc; + CBLAS_INT M, N, P, lda, ldb, ldc; assert(m <= BLAS_MAXSIZE && n <= BLAS_MAXSIZE && p <= BLAS_MAXSIZE); - M = (int)m; - N = (int)n; - P = (int)p; + M = (CBLAS_INT)m; + N = (CBLAS_INT)n; + P = (CBLAS_INT)p; assert(is_blasable2d(os_m, os_p, m, p, sizeof(@typ@))); - ldc = (int)(os_m / sizeof(@typ@)); + ldc = (CBLAS_INT)(os_m / sizeof(@typ@)); if (is_blasable2d(is1_m, is1_n, m, n, sizeof(@typ@))) { trans1 = CblasNoTrans; - lda = (int)(is1_m / sizeof(@typ@)); + lda = (CBLAS_INT)(is1_m / sizeof(@typ@)); } else { /* If not ColMajor, caller should have ensured we are RowMajor */ /* will not assert in release mode */ assert(is_blasable2d(is1_n, is1_m, n, m, sizeof(@typ@))); trans1 = CblasTrans; - lda = (int)(is1_n / sizeof(@typ@)); + lda = (CBLAS_INT)(is1_n / sizeof(@typ@)); } if (is_blasable2d(is2_n, is2_p, n, p, sizeof(@typ@))) { trans2 = CblasNoTrans; - ldb = (int)(is2_n / sizeof(@typ@)); + ldb = (CBLAS_INT)(is2_n / sizeof(@typ@)); } else { /* If not ColMajor, caller should have ensured we are RowMajor */ /* will not assert in release mode */ assert(is_blasable2d(is2_p, is2_n, p, n, sizeof(@typ@))); trans2 = CblasTrans; - ldb = (int)(is2_p / sizeof(@typ@)); + ldb = (CBLAS_INT)(is2_p / sizeof(@typ@)); } /* * Use syrk if we have a case of a matrix times its transpose. @@ -162,12 +166,14 @@ NPY_NO_EXPORT void ) { npy_intp i,j; if (trans1 == CblasNoTrans) { - cblas_@prefix@syrk(order, CblasUpper, trans1, P, N, @step1@, - ip1, lda, @step0@, op, ldc); + CBLAS_FUNC(cblas_@prefix@syrk)( + order, CblasUpper, trans1, P, N, @step1@, + ip1, lda, @step0@, op, ldc); } else { - cblas_@prefix@syrk(order, CblasUpper, trans1, P, N, @step1@, - ip1, ldb, @step0@, op, ldc); + CBLAS_FUNC(cblas_@prefix@syrk)( + order, CblasUpper, trans1, P, N, @step1@, + ip1, ldb, @step0@, op, ldc); } /* Copy the triangle */ for (i = 0; i < P; i++) { @@ -178,8 +184,9 @@ NPY_NO_EXPORT void } else { - cblas_@prefix@gemm(order, trans1, trans2, M, P, N, @step1@, ip1, lda, - ip2, ldb, @step0@, op, ldc); + CBLAS_FUNC(cblas_@prefix@gemm)( + order, trans1, trans2, M, P, N, @step1@, ip1, lda, + ip2, ldb, @step0@, op, ldc); } } From d43645a23af8d3b870bb603b9f6320f9b0c6cd2d Mon Sep 17 00:00:00 2001 From: Pauli Virtanen Date: Sat, 14 Dec 2019 14:14:20 +0200 Subject: [PATCH 0041/4713] DOC: site.cfg: add note about 64-bit openblas library names --- site.cfg.example | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/site.cfg.example b/site.cfg.example index ba912866a4bd..cff0763813d9 100644 --- a/site.cfg.example +++ b/site.cfg.example @@ -165,6 +165,10 @@ # in the same application may cause problems due to symbol name # clashes, especially with embedded Python interpreters. # +# The name of the library file may vary on different systems, so you +# may need to check your specific OpenBLAS installation and +# uncomment and e.g. set ``libraries = openblas`` below. +# # [openblas_ilp64] # libraries = openblas64 # library_dirs = /opt/OpenBLAS/lib From b6f91207549fc97765c114c0c01625eaa5e58956 Mon Sep 17 00:00:00 2001 From: Pauli Virtanen Date: Sat, 14 Dec 2019 14:31:38 +0200 Subject: [PATCH 0042/4713] DOC: f2py: copy documentation for .f2cmap file from old f2py FAQ --- doc/source/f2py/advanced.rst | 49 ++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/doc/source/f2py/advanced.rst b/doc/source/f2py/advanced.rst index c9f3862e62c6..684b83fd700b 100644 --- a/doc/source/f2py/advanced.rst +++ b/doc/source/f2py/advanced.rst @@ -43,3 +43,52 @@ In Python: .. include:: var_session.dat :literal: + + +Dealing with KIND specifiers +============================ + +Currently, F2PY can handle only ``(kind=)`` +declarations where ```` is a numeric integer (e.g. 1, 2, +4,...), but not a function call ``KIND(..)`` or any other +expression. F2PY needs to know what would be the corresponding C type +and a general solution for that would be too complicated to implement. + +However, F2PY provides a hook to overcome this difficulty, namely, +users can define their own to maps. For +example, if Fortran 90 code contains:: + + REAL(kind=KIND(0.0D0)) ... + +then create a file ``.f2py_f2cmap`` (into the working directory) +containing a Python dictionary:: + + {'real': {'KIND(0.0D0)': 'double'}} + +for instance. + +Or more generally, the file ``.f2py_f2cmap`` must contain a dictionary +with items:: + + : {:} + +that defines mapping between Fortran type:: + + ([kind=]) + +and the corresponding . can be one of the following:: + + char + signed_char + short + int + long_long + float + double + long_double + complex_float + complex_double + complex_long_double + string + +For more information, see F2Py source code ``numpy/f2py/capi_maps.py``. From 5a4f62bbf7622530e2a43d1859ae496537e9f0f0 Mon Sep 17 00:00:00 2001 From: Pauli Virtanen Date: Sat, 14 Dec 2019 15:31:50 +0200 Subject: [PATCH 0043/4713] ENH: f2py: add --f2cmap option for specifying the name of .f2py_f2cmap Previously, f2py loaded the type mappings from a file ``.f2py_f2cmap`` in current directory, at import time. Make the file name customizable by adding a ``--f2cmap`` command line option, and postpone loading the file to f2py.run_main(). Moreover, restore the default type mapping in f2py.run_main() before loading the customizations, so that multiple calls to f2py.run_main() do not interfere with each other. (For example, numpy.distutils calls f2py multiple times in the same process.) --- doc/source/f2py/advanced.rst | 9 ++++++--- numpy/f2py/capi_maps.py | 28 ++++++++++++++++++-------- numpy/f2py/f2py2e.py | 15 ++++++++++++-- numpy/f2py/tests/test_assumed_shape.py | 22 ++++++++++++++++++++ numpy/f2py/tests/util.py | 11 +++++----- 5 files changed, 66 insertions(+), 19 deletions(-) diff --git a/doc/source/f2py/advanced.rst b/doc/source/f2py/advanced.rst index 684b83fd700b..375922033d58 100644 --- a/doc/source/f2py/advanced.rst +++ b/doc/source/f2py/advanced.rst @@ -60,14 +60,17 @@ example, if Fortran 90 code contains:: REAL(kind=KIND(0.0D0)) ... -then create a file ``.f2py_f2cmap`` (into the working directory) -containing a Python dictionary:: +then create a mapping file containing a Python dictionary:: {'real': {'KIND(0.0D0)': 'double'}} for instance. -Or more generally, the file ``.f2py_f2cmap`` must contain a dictionary +Use the ``--f2cmap`` command-line option to pass the file name to F2PY. +By default, F2PY assumes file name is ``.f2py_f2cmap`` in the current +working directory. + +Or more generally, the f2cmap file must contain a dictionary with items:: : {:} diff --git a/numpy/f2py/capi_maps.py b/numpy/f2py/capi_maps.py index c41dd77c67fa..ce79f680f2a8 100644 --- a/numpy/f2py/capi_maps.py +++ b/numpy/f2py/capi_maps.py @@ -179,17 +179,29 @@ 'character': {'': 'string'} } -if os.path.isfile('.f2py_f2cmap'): +f2cmap_default = copy.deepcopy(f2cmap_all) + + +def load_f2cmap_file(f2cmap_file): + global f2cmap_all + + f2cmap_all = copy.deepcopy(f2cmap_default) + + if f2cmap_file is None: + # Default value + f2cmap_file = '.f2py_f2cmap' + if not os.path.isfile(f2cmap_file): + return + # User defined additions to f2cmap_all. - # .f2py_f2cmap must contain a dictionary of dictionaries, only. For + # f2cmap_file must contain a dictionary of dictionaries, only. For # example, {'real':{'low':'float'}} means that Fortran 'real(low)' is # interpreted as C 'float'. This feature is useful for F90/95 users if # they use PARAMETERSs in type specifications. try: - outmess('Reading .f2py_f2cmap ...\n') - f = open('.f2py_f2cmap', 'r') - d = eval(f.read(), {}, {}) - f.close() + outmess('Reading f2cmap from {!r} ...\n'.format(f2cmap_file)) + with open(f2cmap_file, 'r') as f: + d = eval(f.read(), {}, {}) for k, d1 in list(d.items()): for k1 in list(d1.keys()): d1[k1.lower()] = d1[k1] @@ -208,10 +220,10 @@ else: errmess("\tIgnoring map {'%s':{'%s':'%s'}}: '%s' must be in %s\n" % ( k, k1, d[k][k1], d[k][k1], list(c2py_map.keys()))) - outmess('Successfully applied user defined changes from .f2py_f2cmap\n') + outmess('Successfully applied user defined f2cmap changes\n') except Exception as msg: errmess( - 'Failed to apply user defined changes from .f2py_f2cmap: %s. Skipping.\n' % (msg)) + 'Failed to apply user defined f2cmap changes: %s. Skipping.\n' % (msg)) cformat_map = {'double': '%g', 'float': '%g', diff --git a/numpy/f2py/f2py2e.py b/numpy/f2py/f2py2e.py index 110337f92641..d03eff9e31b2 100755 --- a/numpy/f2py/f2py2e.py +++ b/numpy/f2py/f2py2e.py @@ -28,6 +28,7 @@ from . import cfuncs from . import f90mod_rules from . import __version__ +from . import capi_maps f2py_version = __version__.version errmess = sys.stderr.write @@ -118,6 +119,9 @@ --link- switch below. [..] is optional list of resources names. E.g. try 'f2py --help-link lapack_opt'. + --f2cmap Load Fortran-to-Python KIND specification from the given + file. Default: .f2py_f2cmap in current directory. + --quiet Run quietly. --verbose Run with extra verbosity. -v Print f2py version ID and exit. @@ -175,7 +179,7 @@ def scaninputline(inputline): files, skipfuncs, onlyfuncs, debug = [], [], [], [] - f, f2, f3, f5, f6, f7, f8, f9 = 1, 0, 0, 0, 0, 0, 0, 0 + f, f2, f3, f5, f6, f7, f8, f9, f10 = 1, 0, 0, 0, 0, 0, 0, 0, 0 verbose = 1 dolc = -1 dolatexdoc = 0 @@ -226,6 +230,8 @@ def scaninputline(inputline): f8 = 1 elif l == '--f2py-wrapper-output': f9 = 1 + elif l == '--f2cmap': + f10 = 1 elif l == '--overwrite-signature': options['h-overwrite'] = 1 elif l == '-h': @@ -267,6 +273,9 @@ def scaninputline(inputline): elif f9: f9 = 0 options["f2py_wrapper_output"] = l + elif f10: + f10 = 0 + options["f2cmap_file"] = l elif f == 1: try: with open(l): @@ -312,6 +321,7 @@ def scaninputline(inputline): options['wrapfuncs'] = wrapfuncs options['buildpath'] = buildpath options['include_paths'] = include_paths + options.setdefault('f2cmap_file', None) return files, options @@ -422,6 +432,7 @@ def run_main(comline_list): fobjcsrc = os.path.join(f2pydir, 'src', 'fortranobject.c') files, options = scaninputline(comline_list) auxfuncs.options = options + capi_maps.load_f2cmap_file(options['f2cmap_file']) postlist = callcrackfortran(files, options) isusedby = {} for i in range(len(postlist)): @@ -574,7 +585,7 @@ def run_compile(): modulename = 'untitled' sources = sys.argv[1:] - for optname in ['--include_paths', '--include-paths']: + for optname in ['--include_paths', '--include-paths', '--f2cmap']: if optname in sys.argv: i = sys.argv.index(optname) f2py_flags.extend(sys.argv[i:i + 2]) diff --git a/numpy/f2py/tests/test_assumed_shape.py b/numpy/f2py/tests/test_assumed_shape.py index 460afd68db6e..e5695a61c11a 100644 --- a/numpy/f2py/tests/test_assumed_shape.py +++ b/numpy/f2py/tests/test_assumed_shape.py @@ -2,6 +2,7 @@ import os import pytest +import tempfile from numpy.testing import assert_ from . import util @@ -16,6 +17,7 @@ class TestAssumedShapeSumExample(util.F2PyTest): _path('src', 'assumed_shape', 'foo_use.f90'), _path('src', 'assumed_shape', 'precision.f90'), _path('src', 'assumed_shape', 'foo_mod.f90'), + _path('src', 'assumed_shape', '.f2py_f2cmap'), ] @pytest.mark.slow @@ -31,3 +33,23 @@ def test_all(self): assert_(r == 3, repr(r)) r = self.module.mod.fsum([1, 2]) assert_(r == 3, repr(r)) + + +class TestF2cmapOption(TestAssumedShapeSumExample): + def setup(self): + # Use a custom file name for .f2py_f2cmap + self.sources = list(self.sources) + f2cmap_src = self.sources.pop(-1) + + self.f2cmap_file = tempfile.NamedTemporaryFile(delete=False) + with open(f2cmap_src, 'rb') as f: + self.f2cmap_file.write(f.read()) + self.f2cmap_file.close() + + self.sources.append(self.f2cmap_file.name) + self.options = ["--f2cmap", self.f2cmap_file.name] + + super(TestF2cmapOption, self).setup() + + def teardown(self): + os.unlink(self.f2cmap_file.name) diff --git a/numpy/f2py/tests/util.py b/numpy/f2py/tests/util.py index 77cb612d0eef..8211a63f067e 100644 --- a/numpy/f2py/tests/util.py +++ b/numpy/f2py/tests/util.py @@ -107,6 +107,7 @@ def build_module(source_files, options=[], skip=[], only=[], module_name=None): # Copy files dst_sources = [] + f2py_sources = [] for fn in source_files: if not os.path.isfile(fn): raise RuntimeError("%s is not a file" % fn) @@ -114,16 +115,14 @@ def build_module(source_files, options=[], skip=[], only=[], module_name=None): shutil.copyfile(fn, dst) dst_sources.append(dst) - fn = os.path.join(os.path.dirname(fn), '.f2py_f2cmap') - if os.path.isfile(fn): - dst = os.path.join(d, os.path.basename(fn)) - if not os.path.isfile(dst): - shutil.copyfile(fn, dst) + base, ext = os.path.splitext(dst) + if ext in ('.f90', '.f', '.c', '.pyf'): + f2py_sources.append(dst) # Prepare options if module_name is None: module_name = get_temp_module_name() - f2py_opts = ['-c', '-m', module_name] + options + dst_sources + f2py_opts = ['-c', '-m', module_name] + options + f2py_sources if skip: f2py_opts += ['skip:'] + skip if only: From 66b17db5e9dd182812dfd1de77b2874cf070e00e Mon Sep 17 00:00:00 2001 From: Pauli Virtanen Date: Sat, 14 Dec 2019 15:40:42 +0200 Subject: [PATCH 0044/4713] TST: f2py: fix race condition in f2py test _get_compiler_status Distutils code needs to run in different temporary directories, probably because they create `_configtest.c` files for compiler detection in the current directory. --- numpy/f2py/tests/util.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/numpy/f2py/tests/util.py b/numpy/f2py/tests/util.py index 8211a63f067e..bf005df882ae 100644 --- a/numpy/f2py/tests/util.py +++ b/numpy/f2py/tests/util.py @@ -204,14 +204,20 @@ def configuration(parent_name='',top_path=None): """) code = code % dict(syspath=repr(sys.path)) - with temppath(suffix='.py') as script: + tmpdir = tempfile.mkdtemp() + try: + script = os.path.join(tmpdir, 'setup.py') + with open(script, 'w') as f: f.write(code) - cmd = [sys.executable, script, 'config'] + cmd = [sys.executable, 'setup.py', 'config'] p = subprocess.Popen(cmd, stdout=subprocess.PIPE, - stderr=subprocess.STDOUT) + stderr=subprocess.STDOUT, + cwd=tmpdir) out, err = p.communicate() + finally: + shutil.rmtree(tmpdir) m = re.search(br'COMPILERS:(\d+),(\d+),(\d+)', out) if m: From 7142a6c979d6cb2fb514e6974bdb2639d387015a Mon Sep 17 00:00:00 2001 From: Pauli Virtanen Date: Sat, 14 Dec 2019 18:35:41 +0200 Subject: [PATCH 0045/4713] DOC: add release note for f2py --f2cmap --- doc/release/upcoming_changes/15106.new_feature.rst | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 doc/release/upcoming_changes/15106.new_feature.rst diff --git a/doc/release/upcoming_changes/15106.new_feature.rst b/doc/release/upcoming_changes/15106.new_feature.rst new file mode 100644 index 000000000000..9f1d0b247909 --- /dev/null +++ b/doc/release/upcoming_changes/15106.new_feature.rst @@ -0,0 +1,4 @@ +Add ``--f2cmap`` option to F2PY +------------------------------- +Allow specifying a file to load Fortran-to-C type map +customizations from. From 3814538ef632d228ba3c2edc29e11a5b383bfc57 Mon Sep 17 00:00:00 2001 From: Pauli Virtanen Date: Sat, 14 Dec 2019 18:46:15 +0200 Subject: [PATCH 0046/4713] DOC: adjust ILP64 openblas release note --- doc/source/release/1.18.0-notes.rst | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/doc/source/release/1.18.0-notes.rst b/doc/source/release/1.18.0-notes.rst index 76b358d98a86..dc0c4ce84759 100644 --- a/doc/source/release/1.18.0-notes.rst +++ b/doc/source/release/1.18.0-notes.rst @@ -205,10 +205,9 @@ The `numpy.expand_dims` ``axis`` keyword can now accept a tuple of axes. Previously, ``axis`` was required to be an integer. (`gh-14051 `__) -Support for 64-bit OpenBLAS with symbol suffix ----------------------------------------------- -Added support for 64-bit (ILP64) OpenBLAS compiled with -``make INTERFACE64=1 SYMBOLSUFFIX=64_``. See ``site.cfg.example`` +Support for 64-bit OpenBLAS +--------------------------- +Added support for 64-bit (ILP64) OpenBLAS. See ``site.cfg.example`` for details. Improvements From 85447b1ed7df98aff0ed9d666a92f8714f08c2ee Mon Sep 17 00:00:00 2001 From: Pauli Virtanen Date: Sat, 14 Dec 2019 18:47:43 +0200 Subject: [PATCH 0047/4713] DOC: explain NPY_*_ILP64_ORDER default values --- doc/source/user/building.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/source/user/building.rst b/doc/source/user/building.rst index 8e9744a877be..1588de964c90 100644 --- a/doc/source/user/building.rst +++ b/doc/source/user/building.rst @@ -211,7 +211,7 @@ supported: The order in which they are preferred is determined by ``NPY_BLAS_ILP64_ORDER`` and ``NPY_LAPACK_ILP64_ORDER`` environment -variables, similarly as above. +variables. The default value is ``openblas64_,openblas_ilp64``. .. note:: From d920a80bbda99562b50ff5296ebcdb2c81e8e8d5 Mon Sep 17 00:00:00 2001 From: Warren Weckesser Date: Sun, 15 Dec 2019 21:48:38 -0500 Subject: [PATCH 0048/4713] MAINT: random: Remove a few unused imports from test files. --- numpy/random/tests/test_generator_mt19937.py | 1 - numpy/random/tests/test_generator_mt19937_regressions.py | 1 - numpy/random/tests/test_smoke.py | 1 - 3 files changed, 3 deletions(-) diff --git a/numpy/random/tests/test_generator_mt19937.py b/numpy/random/tests/test_generator_mt19937.py index d835f16bd7b2..5b3d5f08a812 100644 --- a/numpy/random/tests/test_generator_mt19937.py +++ b/numpy/random/tests/test_generator_mt19937.py @@ -3,7 +3,6 @@ import pytest import numpy as np -from numpy.dual import cholesky, eigh, svd from numpy.linalg import LinAlgError from numpy.testing import ( assert_, assert_raises, assert_equal, assert_allclose, diff --git a/numpy/random/tests/test_generator_mt19937_regressions.py b/numpy/random/tests/test_generator_mt19937_regressions.py index 3a937f997a43..7ca8b9f3caf1 100644 --- a/numpy/random/tests/test_generator_mt19937_regressions.py +++ b/numpy/random/tests/test_generator_mt19937_regressions.py @@ -1,4 +1,3 @@ -import sys from numpy.testing import (assert_, assert_array_equal) from numpy.compat import long import numpy as np diff --git a/numpy/random/tests/test_smoke.py b/numpy/random/tests/test_smoke.py index 58ef6a09af0d..cdaac5ebb694 100644 --- a/numpy/random/tests/test_smoke.py +++ b/numpy/random/tests/test_smoke.py @@ -1,5 +1,4 @@ import pickle -import time from functools import partial import numpy as np From b9b8798967ee00e1269f264711c7a1d4f97b006e Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Mon, 16 Dec 2019 07:29:02 +0000 Subject: [PATCH 0049/4713] MAINT: Bump pytest from 5.3.1 to 5.3.2 Bumps [pytest](https://github.com/pytest-dev/pytest) from 5.3.1 to 5.3.2. - [Release notes](https://github.com/pytest-dev/pytest/releases) - [Changelog](https://github.com/pytest-dev/pytest/blob/master/CHANGELOG.rst) - [Commits](https://github.com/pytest-dev/pytest/compare/5.3.1...5.3.2) Signed-off-by: dependabot-preview[bot] --- test_requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test_requirements.txt b/test_requirements.txt index 627150673a40..8ca2ce87bcfd 100644 --- a/test_requirements.txt +++ b/test_requirements.txt @@ -1,5 +1,5 @@ cython==0.29.14 -pytest==5.3.1 +pytest==5.3.2 pytz==2019.3 pytest-cov==2.8.1 pickle5; python_version == '3.7' From 5d9cab95e6b955c400835c31c2769625d0234c03 Mon Sep 17 00:00:00 2001 From: Till Hoffmann Date: Sun, 15 Dec 2019 17:04:38 +0000 Subject: [PATCH 0050/4713] BUG: Fix expm1 instability for small complex nums. --- numpy/core/src/umath/funcs.inc.src | 6 +++--- numpy/core/tests/test_umath.py | 6 ++++++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/numpy/core/src/umath/funcs.inc.src b/numpy/core/src/umath/funcs.inc.src index 10ed66e50ef2..397d2c1aaf49 100644 --- a/numpy/core/src/umath/funcs.inc.src +++ b/numpy/core/src/umath/funcs.inc.src @@ -360,9 +360,9 @@ nc_exp2@c@(@ctype@ *x, @ctype@ *r) static void nc_expm1@c@(@ctype@ *x, @ctype@ *r) { - @ftype@ a = npy_exp@c@(x->real); - r->real = a*npy_cos@c@(x->imag) - 1.0@c@; - r->imag = a*npy_sin@c@(x->imag); + @ftype@ a = npy_cos@c@(x->imag); + r->real = npy_expm1@c@(x->real) * a + (a - 1); + r->imag = npy_exp@c@(x->real) * npy_sin@c@(x->imag); return; } diff --git a/numpy/core/tests/test_umath.py b/numpy/core/tests/test_umath.py index e892e81d23c6..ae1090c23ebd 100644 --- a/numpy/core/tests/test_umath.py +++ b/numpy/core/tests/test_umath.py @@ -888,6 +888,12 @@ def test_special(self): assert_equal(ncu.expm1(np.inf), np.inf) assert_equal(ncu.expm1(-np.inf), -1.) + def test_complex(self): + x = np.asarray(1e-12) + assert_allclose(x, ncu.expm1(x)) + x = x.astype(np.complex128) + assert_allclose(x, ncu.expm1(x)) + class TestHypot(object): def test_simple(self): From 253084777f4b9aeb517253dbe5059fb90bf57a96 Mon Sep 17 00:00:00 2001 From: Till Hoffmann Date: Mon, 16 Dec 2019 08:16:25 +0000 Subject: [PATCH 0051/4713] MAINT: Use trig identity to evaluate cosm1. --- numpy/core/src/umath/funcs.inc.src | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/numpy/core/src/umath/funcs.inc.src b/numpy/core/src/umath/funcs.inc.src index 397d2c1aaf49..9c59cc8fbbdd 100644 --- a/numpy/core/src/umath/funcs.inc.src +++ b/numpy/core/src/umath/funcs.inc.src @@ -360,8 +360,8 @@ nc_exp2@c@(@ctype@ *x, @ctype@ *r) static void nc_expm1@c@(@ctype@ *x, @ctype@ *r) { - @ftype@ a = npy_cos@c@(x->imag); - r->real = npy_expm1@c@(x->real) * a + (a - 1); + @ftype@ a = npy_sin@c@(x->imag / 2); + r->real = npy_expm1@c@(x->real) * npy_cos@c@(x->imag) - 2 * a * a; r->imag = npy_exp@c@(x->real) * npy_sin@c@(x->imag); return; } From 28848d79f665ec2dd83e84de14542a6e0ed645a5 Mon Sep 17 00:00:00 2001 From: mattip Date: Mon, 16 Dec 2019 22:19:55 +0200 Subject: [PATCH 0052/4713] BLD: fix signed-unsigned comparison warning --- numpy/core/src/umath/simd.inc.src | 6 +++--- tools/travis-test.sh | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/numpy/core/src/umath/simd.inc.src b/numpy/core/src/umath/simd.inc.src index 74f52cc9d529..1f29526be4dd 100644 --- a/numpy/core/src/umath/simd.inc.src +++ b/numpy/core/src/umath/simd.inc.src @@ -280,11 +280,11 @@ run_binary_simd_@kind@_@TYPE@(char **args, npy_intp *dimensions, npy_intp *steps @type@ * op = (@type@ *)args[2]; npy_intp n = dimensions[0]; #if defined __AVX512F__ - const npy_intp vector_size_bytes = 64; + const npy_uintp vector_size_bytes = 64; #elif defined __AVX2__ - const npy_intp vector_size_bytes = 32; + const npy_uintp vector_size_bytes = 32; #else - const npy_intp vector_size_bytes = 32; + const npy_uintp vector_size_bytes = 32; #endif /* argument one scalar */ if (IS_BLOCKABLE_BINARY_SCALAR1(sizeof(@type@), vector_size_bytes)) { diff --git a/tools/travis-test.sh b/tools/travis-test.sh index 241b9d913c9d..da9195d4dc42 100755 --- a/tools/travis-test.sh +++ b/tools/travis-test.sh @@ -155,7 +155,7 @@ if [ -n "$USE_WHEEL" ] && [ $# -eq 0 ]; then export F90='gfortran --coverage' export LDFLAGS='--coverage' fi - $PYTHON setup.py build build_src --verbose-cfg bdist_wheel + $PYTHON setup.py build --warn-error build_src --verbose-cfg bdist_wheel # Make another virtualenv to install into virtualenv --python=`which $PYTHON` venv-for-wheel . venv-for-wheel/bin/activate From e91f1441f69ea87bc64bec82cfac75eb06282ac3 Mon Sep 17 00:00:00 2001 From: Bharat Raghunathan Date: Wed, 18 Dec 2019 08:31:21 +0530 Subject: [PATCH 0053/4713] DOC: Update documentation of np.clip --- numpy/core/fromnumeric.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/numpy/core/fromnumeric.py b/numpy/core/fromnumeric.py index f09f2a465d0e..9f55e104ce7a 100644 --- a/numpy/core/fromnumeric.py +++ b/numpy/core/fromnumeric.py @@ -2033,7 +2033,8 @@ def clip(a, a_min, a_max, out=None, **kwargs): is specified, values smaller than 0 become 0, and values larger than 1 become 1. - Equivalent to but faster than ``np.maximum(a_min, np.minimum(a, a_max))``. + Equivalent to but faster than ``np.maximum(a_min, np.minimum(a, a_max))`` + only if ``a_min < a_max`` else returns ``a_max``. No check is performed to ensure ``a_min < a_max``. Parameters From 09cd87ca17004651866fce1849357f15a7ac2230 Mon Sep 17 00:00:00 2001 From: Bharat Raghunathan Date: Wed, 18 Dec 2019 18:22:19 +0530 Subject: [PATCH 0054/4713] Doc changes per review --- numpy/core/fromnumeric.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/numpy/core/fromnumeric.py b/numpy/core/fromnumeric.py index 9f55e104ce7a..33b3b5703436 100644 --- a/numpy/core/fromnumeric.py +++ b/numpy/core/fromnumeric.py @@ -2034,7 +2034,7 @@ def clip(a, a_min, a_max, out=None, **kwargs): than 1 become 1. Equivalent to but faster than ``np.maximum(a_min, np.minimum(a, a_max))`` - only if ``a_min < a_max`` else returns ``a_max``. + assuming ``a_min < a_max``. No check is performed to ensure ``a_min < a_max``. Parameters From fffa116f53ddf223573e12e07a74d2e62e6ecad0 Mon Sep 17 00:00:00 2001 From: Kevin Sheppard Date: Wed, 18 Dec 2019 16:02:30 +0000 Subject: [PATCH 0055/4713] DOC: Remove reference to basic RNG Remove reference to outdated basic RNG --- doc/source/reference/random/extending.rst | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/doc/source/reference/random/extending.rst b/doc/source/reference/random/extending.rst index 4adb90c06297..52063ae5bfe6 100644 --- a/doc/source/reference/random/extending.rst +++ b/doc/source/reference/random/extending.rst @@ -41,8 +41,8 @@ wrap around, providing array alignment information -- still apply. :language: cython :end-before: example 2 -The BitGenerator can also be directly accessed using the members of the basic -RNG structure. +The BitGenerator can also be directly accessed using the members of the ``bitgen_t`` +struct. .. literalinclude:: ../../../../numpy/random/_examples/cython/extending_distributions.pyx :language: cython @@ -70,9 +70,9 @@ directly from the ``_generator`` shared object, using the `BitGenerator.cffi` in :start-after: dlopen -New Basic RNGs -============== -`~Generator` can be used with other user-provided BitGenerators. The simplest +New Bit Generators +================== +`~Generator` can be used with user-provided `~BitGenerator`\ s. The simplest way to write a new BitGenerator is to examine the pyx file of one of the existing BitGenerators. The key structure that must be provided is the ``capsule`` which contains a ``PyCapsule`` to a struct pointer of type From 6d69a9e163858de5d0ea2ae810b8febc7eec1dbc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nico=20Schl=C3=B6mer?= Date: Wed, 18 Dec 2019 22:14:26 +0100 Subject: [PATCH 0056/4713] MAINT: Fix randint 0d limits and other 0d cleanups (#15126) * MAINT: only treat 0d case separately in randint, simplify some tests --- numpy/core/tests/test_machar.py | 2 +- numpy/core/tests/test_multiarray.py | 2 +- numpy/random/_bounded_integers.pyx.in | 3 +-- numpy/testing/tests/test_utils.py | 6 +++--- 4 files changed, 6 insertions(+), 7 deletions(-) diff --git a/numpy/core/tests/test_machar.py b/numpy/core/tests/test_machar.py index ab8800c09d30..64a0ffa3db68 100644 --- a/numpy/core/tests/test_machar.py +++ b/numpy/core/tests/test_machar.py @@ -16,7 +16,7 @@ def _run_machar_highprec(self): # underflow try: hiprec = ntypes.float96 - MachAr(lambda v:array([v], hiprec)) + MachAr(lambda v: array(v, hiprec)) except AttributeError: # Fixme, this needs to raise a 'skip' exception. "Skipping test: no ntypes.float96 available on this platform." diff --git a/numpy/core/tests/test_multiarray.py b/numpy/core/tests/test_multiarray.py index ae4e89d5b373..d801dbf917ce 100644 --- a/numpy/core/tests/test_multiarray.py +++ b/numpy/core/tests/test_multiarray.py @@ -7564,8 +7564,8 @@ def test_to_int_scalar(self): # gh-9972 means that these aren't always the same int_funcs = (int, lambda x: x.__int__()) for int_func in int_funcs: + assert_equal(int_func(np.array(0)), 0) assert_equal(int_func(np.array([1])), 1) - assert_equal(int_func(np.array([0])), 0) assert_equal(int_func(np.array([[42]])), 42) assert_raises(TypeError, int_func, np.array([1, 2])) diff --git a/numpy/random/_bounded_integers.pyx.in b/numpy/random/_bounded_integers.pyx.in index 7e19471e49c4..9e639b53b189 100644 --- a/numpy/random/_bounded_integers.pyx.in +++ b/numpy/random/_bounded_integers.pyx.in @@ -314,8 +314,7 @@ cdef object _rand_{{nptype}}(object low, object high, object size, high_arr = np.array(high, copy=False) low_ndim = np.PyArray_NDIM(low_arr) high_ndim = np.PyArray_NDIM(high_arr) - if ((low_ndim == 0 or (low_ndim == 1 and low_arr.size == 1 and size is not None)) and - (high_ndim == 0 or (high_ndim == 1 and high_arr.size == 1 and size is not None))): + if low_ndim == 0 and high_ndim == 0: low = int(low_arr) high = int(high_arr) # Subtract 1 since internal generator produces on closed interval [low, high] diff --git a/numpy/testing/tests/test_utils.py b/numpy/testing/tests/test_utils.py index 44f93a693d88..d14d4090c7df 100644 --- a/numpy/testing/tests/test_utils.py +++ b/numpy/testing/tests/test_utils.py @@ -608,9 +608,9 @@ class TestApproxEqual(object): def setup(self): self._assert_func = assert_approx_equal - def test_simple_arrays(self): - x = np.array([1234.22]) - y = np.array([1234.23]) + def test_simple_0d_arrays(self): + x = np.array(1234.22) + y = np.array(1234.23) self._assert_func(x, y, significant=5) self._assert_func(x, y, significant=6) From 0c2a5eb42c0cddf6844880f1494ddf7765bf9c7b Mon Sep 17 00:00:00 2001 From: Brian Wignall Date: Thu, 19 Dec 2019 03:39:59 -0500 Subject: [PATCH 0057/4713] Fix typos, via a Levenshtein-style corrector --- doc/Makefile | 2 +- doc/neps/nep-0023-backwards-compatibility.rst | 2 +- doc/neps/nep-0028-website-redesign.rst | 2 +- doc/release/upcoming_changes/14933.compatibility.rst | 2 +- doc/source/dev/development_workflow.rst | 2 +- doc/source/dev/governance/governance.rst | 2 +- doc/source/reference/c-api/coremath.rst | 4 ++-- doc/source/reference/random/legacy.rst | 2 +- doc/source/release/1.17.0-notes.rst | 2 +- numpy/_pytesttester.py | 2 +- numpy/compat/py3k.py | 2 +- numpy/core/defchararray.py | 4 ++-- numpy/core/src/multiarray/arraytypes.c.src | 2 +- numpy/core/src/multiarray/buffer.c | 2 +- numpy/core/src/multiarray/iterators.c | 2 +- numpy/core/tests/test_dtype.py | 2 +- numpy/doc/dispatch.py | 2 +- numpy/f2py/capi_maps.py | 2 +- numpy/linalg/lapack_lite/f2c.c | 4 ++-- numpy/linalg/lapack_lite/f2c_blas.c | 8 ++++---- numpy/linalg/lapack_lite/fortran.py | 2 +- numpy/random/src/philox/philox-benchmark.c | 2 +- numpy/testing/_private/parameterized.py | 2 +- 23 files changed, 29 insertions(+), 29 deletions(-) diff --git a/doc/Makefile b/doc/Makefile index 74272fa50db6..199a22c34e5a 100644 --- a/doc/Makefile +++ b/doc/Makefile @@ -158,7 +158,7 @@ endif @# the instructions in doc/HOWTO_RELEASE.rst.txt @echo " " @echo New documentation archive added to ./build/merge. - @echo Now add/modify the appropiate section after + @echo Now add/modify the appropriate section after @echo " " @echo in build/merge/index.html, @echo then \"git commit\", \"git push\" diff --git a/doc/neps/nep-0023-backwards-compatibility.rst b/doc/neps/nep-0023-backwards-compatibility.rst index 158b08f1f18d..92974ad6ea2b 100644 --- a/doc/neps/nep-0023-backwards-compatibility.rst +++ b/doc/neps/nep-0023-backwards-compatibility.rst @@ -198,7 +198,7 @@ Policy can be made, *provided the benefit is worth the cost* and suitable deprecation warnings have been raised first. 3. Deprecation warnings are in all cases warnings that functionality will be removed. - If there is no intent to remove functionlity, then deprecation in documentation + If there is no intent to remove functionality, then deprecation in documentation only or other types of warnings shall be used. 4. Deprecations for stylistic reasons (e.g. consistency between functions) are strongly discouraged. diff --git a/doc/neps/nep-0028-website-redesign.rst b/doc/neps/nep-0028-website-redesign.rst index b418ca831b32..dcd182d55138 100644 --- a/doc/neps/nep-0028-website-redesign.rst +++ b/doc/neps/nep-0028-website-redesign.rst @@ -166,7 +166,7 @@ have a similar deployment to GitHub Pages or Netlify. Analytics ~~~~~~~~~ -It's benefical to maintainers to know how many visitors are coming to +It's beneficial to maintainers to know how many visitors are coming to numpy.org. Google Analytics offers visitor counts and locations. This will help to support and deploy more strategically, and help maintainers understand where traffic is coming from. diff --git a/doc/release/upcoming_changes/14933.compatibility.rst b/doc/release/upcoming_changes/14933.compatibility.rst index b939fec7f01f..1b5f1b113ddc 100644 --- a/doc/release/upcoming_changes/14933.compatibility.rst +++ b/doc/release/upcoming_changes/14933.compatibility.rst @@ -5,6 +5,6 @@ The promotion of mixed scalars and arrays in ``PyArray_ConvertToCommonType`` has been changed to adhere to those used by ``np.result_type``. This means that input such as ``(1000, np.array([1], dtype=np.uint8)))`` will now return ``uint16`` dtypes. In most cases the behaviour is unchanged. -Note that the use of this C-API function is generally discouarged. +Note that the use of this C-API function is generally discouraged. This also fixes ``np.choose`` to behave the same way as the rest of NumPy in this respect. diff --git a/doc/source/dev/development_workflow.rst b/doc/source/dev/development_workflow.rst index 900431374454..9f2ecede6e1b 100644 --- a/doc/source/dev/development_workflow.rst +++ b/doc/source/dev/development_workflow.rst @@ -303,7 +303,7 @@ Suppose that the commit history looks like this:: 2dec1ac Fix a few bugs + disable 13d7934 First implementation 6ad92e5 * masked is now an instance of a new object, MaskedConstant - 29001ed Add pre-nep for a copule of structured_array_extensions. + 29001ed Add pre-nep for a couple of structured_array_extensions. ... and ``6ad92e5`` is the last commit in the ``master`` branch. Suppose we diff --git a/doc/source/dev/governance/governance.rst b/doc/source/dev/governance/governance.rst index 54e52363c00d..d8719700f2da 100644 --- a/doc/source/dev/governance/governance.rst +++ b/doc/source/dev/governance/governance.rst @@ -301,7 +301,7 @@ its interactions with NumFOCUS. or technical direction of the Project. - This Subcommittee will have 5 members, 4 of whom will be current Council Members and 1 of whom will be external to the Steering - Council. No more than 2 Subcommitee Members can report to one person + Council. No more than 2 Subcommittee Members can report to one person through employment or contracting work (including the reportee, i.e. the reportee + 1 is the max). This avoids effective majorities resting on one person. diff --git a/doc/source/reference/c-api/coremath.rst b/doc/source/reference/c-api/coremath.rst index 7e00322f96a8..4200f4ba8bbd 100644 --- a/doc/source/reference/c-api/coremath.rst +++ b/doc/source/reference/c-api/coremath.rst @@ -193,7 +193,7 @@ Those can be useful for precise floating point comparison. .. c:function:: int npy_get_floatstatus_barrier(char*) Get floating point status. A pointer to a local variable is passed in to - prevent aggressive compiler optimizations from reodering this function call + prevent aggressive compiler optimizations from reordering this function call relative to the code setting the status, which could lead to incorrect results. @@ -219,7 +219,7 @@ Those can be useful for precise floating point comparison. .. c:function:: int npy_clear_floatstatus_barrier(char*) Clears the floating point status. A pointer to a local variable is passed in to - prevent aggressive compiler optimizations from reodering this function call. + prevent aggressive compiler optimizations from reordering this function call. Returns the previous status mask. .. versionadded:: 1.15.0 diff --git a/doc/source/reference/random/legacy.rst b/doc/source/reference/random/legacy.rst index 922d76a9ae8a..91b91dac89d9 100644 --- a/doc/source/reference/random/legacy.rst +++ b/doc/source/reference/random/legacy.rst @@ -125,7 +125,7 @@ Distributions Functions in `numpy.random` =========================== Many of the RandomState methods above are exported as functions in -`numpy.random` This usage is discouraged, as it is implemented via a gloabl +`numpy.random` This usage is discouraged, as it is implemented via a global `RandomState` instance which is not advised on two counts: - It uses global state, which means results will change as the code changes diff --git a/doc/source/release/1.17.0-notes.rst b/doc/source/release/1.17.0-notes.rst index a0e7379824c1..a93eb21863e5 100644 --- a/doc/source/release/1.17.0-notes.rst +++ b/doc/source/release/1.17.0-notes.rst @@ -297,7 +297,7 @@ mergesort. Due to the need to maintain backward compatibility, the sorting ``kind`` options ``"stable"`` and ``"mergesort"`` have been made aliases of each other with the actual sort implementation depending on the array type. Radix sort is used for small integer types of 16 bits or less and timsort for -the remaining types. Timsort features improved performace on data containing +the remaining types. Timsort features improved performance on data containing already or nearly sorted data and performs like mergesort on random data and requires :math:`O(n/2)` working space. Details of the timsort algorithm can be found at `CPython listsort.txt diff --git a/numpy/_pytesttester.py b/numpy/_pytesttester.py index b25224c2037f..6462fc5e60f1 100644 --- a/numpy/_pytesttester.py +++ b/numpy/_pytesttester.py @@ -15,7 +15,7 @@ whether or not that file is found as follows: * ``pytest.ini`` is present (develop mode) - All warnings except those explicily filtered out are raised as error. + All warnings except those explicitly filtered out are raised as error. * ``pytest.ini`` is absent (release mode) DeprecationWarnings and PendingDeprecationWarnings are ignored, other warnings are passed through. diff --git a/numpy/compat/py3k.py b/numpy/compat/py3k.py index 90e17d6d6b99..f24a8af27f9c 100644 --- a/numpy/compat/py3k.py +++ b/numpy/compat/py3k.py @@ -1,7 +1,7 @@ """ Python 3.X compatibility tools. -While this file was originally intented for Python 2 -> 3 transition, +While this file was originally intended for Python 2 -> 3 transition, it is now used to create a compatibility layer between different minor versions of Python 3. diff --git a/numpy/core/defchararray.py b/numpy/core/defchararray.py index 2d89d6fe08af..168fd8c790ae 100644 --- a/numpy/core/defchararray.py +++ b/numpy/core/defchararray.py @@ -358,7 +358,7 @@ def _mod_dispatcher(a, values): def mod(a, values): """ Return (a % i), that is pre-Python 2.6 string formatting - (iterpolation), element-wise for a pair of array_likes of str + (interpolation), element-wise for a pair of array_likes of str or unicode. Parameters @@ -2112,7 +2112,7 @@ def __rmul__(self, i): def __mod__(self, i): """ Return (self % i), that is pre-Python 2.6 string formatting - (iterpolation), element-wise for a pair of array_likes of `string_` + (interpolation), element-wise for a pair of array_likes of `string_` or `unicode_`. See also diff --git a/numpy/core/src/multiarray/arraytypes.c.src b/numpy/core/src/multiarray/arraytypes.c.src index 9e108e3e140a..99897f9c2466 100644 --- a/numpy/core/src/multiarray/arraytypes.c.src +++ b/numpy/core/src/multiarray/arraytypes.c.src @@ -4193,7 +4193,7 @@ _datetime_dtype_metadata_clone(NpyAuxData *data) } /* - * Allcoate and initialize a PyArray_DatetimeDTypeMetaData object + * Allocate and initialize a PyArray_DatetimeDTypeMetaData object */ static NpyAuxData* _create_datetime_metadata(NPY_DATETIMEUNIT base, int num) diff --git a/numpy/core/src/multiarray/buffer.c b/numpy/core/src/multiarray/buffer.c index 0edadee982c2..2939a2e390ea 100644 --- a/numpy/core/src/multiarray/buffer.c +++ b/numpy/core/src/multiarray/buffer.c @@ -523,7 +523,7 @@ _buffer_info_new(PyObject *obj) /* * Special case datetime64 scalars to remain backward compatible. * This will change in a future version. - * Note arrays of datetime64 and strutured arrays with datetime64 + * Note arrays of datetime64 and structured arrays with datetime64 * fields will not hit this code path and are currently unsupported * in _buffer_format_string. */ diff --git a/numpy/core/src/multiarray/iterators.c b/numpy/core/src/multiarray/iterators.c index e66bb36aa9a3..1ee0a4d60653 100644 --- a/numpy/core/src/multiarray/iterators.c +++ b/numpy/core/src/multiarray/iterators.c @@ -172,7 +172,7 @@ NPY_NO_EXPORT PyObject * PyArray_IterNew(PyObject *obj) { /* - * Note that internall PyArray_RawIterBaseInit may be called directly on a + * Note that internally PyArray_RawIterBaseInit may be called directly on a * statically allocated PyArrayIterObject. */ PyArrayIterObject *it; diff --git a/numpy/core/tests/test_dtype.py b/numpy/core/tests/test_dtype.py index e18e66c649bc..b347a9de7cf8 100644 --- a/numpy/core/tests/test_dtype.py +++ b/numpy/core/tests/test_dtype.py @@ -732,7 +732,7 @@ def test_sparse_field_assignment(self): assert_array_equal(arr["a"]["aa"], np.zeros((3, 2, 3))) def test_sparse_field_assignment_fancy(self): - # Fancy assignment goes to the copyswap function for comlex types: + # Fancy assignment goes to the copyswap function for complex types: arr = np.zeros(3, self.dtype) sparse_arr = arr.view(self.sparse_dtype) diff --git a/numpy/doc/dispatch.py b/numpy/doc/dispatch.py index c9029941b52a..ba76a43ae563 100644 --- a/numpy/doc/dispatch.py +++ b/numpy/doc/dispatch.py @@ -58,7 +58,7 @@ How can we pass our custom array type through this function? Numpy allows a class to indicate that it would like to handle computations in a custom-defined -way through the interaces ``__array_ufunc__`` and ``__array_function__``. Let's +way through the interfaces ``__array_ufunc__`` and ``__array_function__``. Let's take one at a time, starting with ``_array_ufunc__``. This method covers :ref:`ufuncs`, a class of functions that includes, for example, :func:`numpy.multiply` and :func:`numpy.sin`. diff --git a/numpy/f2py/capi_maps.py b/numpy/f2py/capi_maps.py index ce79f680f2a8..917a4a9a3ad1 100644 --- a/numpy/f2py/capi_maps.py +++ b/numpy/f2py/capi_maps.py @@ -79,7 +79,7 @@ 'complex_long_double': 'NPY_CDOUBLE', # forced casting 'string': 'NPY_STRING'} -# These new maps aren't used anyhere yet, but should be by default +# These new maps aren't used anywhere yet, but should be by default # unless building numeric or numarray extensions. if using_newcore: c2capi_map = {'double': 'NPY_DOUBLE', diff --git a/numpy/linalg/lapack_lite/f2c.c b/numpy/linalg/lapack_lite/f2c.c index 1114bef3b1c3..9a1e9cec1d2b 100644 --- a/numpy/linalg/lapack_lite/f2c.c +++ b/numpy/linalg/lapack_lite/f2c.c @@ -567,7 +567,7 @@ if( (abi = b->i) < 0.f) abi = - abi; if( abr <= abi ) { - /*Let IEEE Infinties handle this ;( */ + /*Let IEEE Infinities handle this ;( */ /*if(abi == 0) sig_die("complex division by zero", 1);*/ ratio = b->r / b->i ; @@ -603,7 +603,7 @@ if( (abi = b->i) < 0.) abi = - abi; if( abr <= abi ) { - /*Let IEEE Infinties handle this ;( */ + /*Let IEEE Infinities handle this ;( */ /*if(abi == 0) sig_die("complex division by zero", 1);*/ ratio = b->r / b->i ; diff --git a/numpy/linalg/lapack_lite/f2c_blas.c b/numpy/linalg/lapack_lite/f2c_blas.c index 3af506b71247..44ad23bfe541 100644 --- a/numpy/linalg/lapack_lite/f2c_blas.c +++ b/numpy/linalg/lapack_lite/f2c_blas.c @@ -4912,7 +4912,7 @@ static doublecomplex c_b1078 = {1.,0.}; ( 1 + ( n - 1 )*abs( INCX ) ). Before entry, the incremented array X must contain the n element vector x. On exit, X is overwritten with the - tranformed vector x. + transformed vector x. INCX - INTEGER. On entry, INCX specifies the increment for the elements of @@ -9807,7 +9807,7 @@ doublereal dnrm2_(integer *n, doublereal *x, integer *incx) ( 1 + ( n - 1 )*abs( INCX ) ). Before entry, the incremented array X must contain the n element vector x. On exit, X is overwritten with the - tranformed vector x. + transformed vector x. INCX - INTEGER. On entry, INCX specifies the increment for the elements of @@ -14410,7 +14410,7 @@ doublereal snrm2_(integer *n, real *x, integer *incx) ( 1 + ( n - 1 )*abs( INCX ) ). Before entry, the incremented array X must contain the n element vector x. On exit, X is overwritten with the - tranformed vector x. + transformed vector x. INCX - INTEGER. On entry, INCX specifies the increment for the elements of @@ -19998,7 +19998,7 @@ doublereal snrm2_(integer *n, real *x, integer *incx) ( 1 + ( n - 1 )*abs( INCX ) ). Before entry, the incremented array X must contain the n element vector x. On exit, X is overwritten with the - tranformed vector x. + transformed vector x. INCX - INTEGER. On entry, INCX specifies the increment for the elements of diff --git a/numpy/linalg/lapack_lite/fortran.py b/numpy/linalg/lapack_lite/fortran.py index dc0a5ebd90ba..671f14d24c45 100644 --- a/numpy/linalg/lapack_lite/fortran.py +++ b/numpy/linalg/lapack_lite/fortran.py @@ -14,7 +14,7 @@ def isContinuation(line): COMMENT, STATEMENT, CONTINUATION = 0, 1, 2 def lineType(line): - """Return the type of a line of Fortan code.""" + """Return the type of a line of Fortran code.""" if isBlank(line): return COMMENT elif isLabel(line): diff --git a/numpy/random/src/philox/philox-benchmark.c b/numpy/random/src/philox/philox-benchmark.c index df5814d5f518..9856a9b8e2a4 100644 --- a/numpy/random/src/philox/philox-benchmark.c +++ b/numpy/random/src/philox/philox-benchmark.c @@ -1,5 +1,5 @@ /* - * Simple benchamrk command + * Simple benchmark command * * cl philox-benchmark.c /Ox * diff --git a/numpy/testing/_private/parameterized.py b/numpy/testing/_private/parameterized.py index 489d8e09a0ad..2134cca88c22 100644 --- a/numpy/testing/_private/parameterized.py +++ b/numpy/testing/_private/parameterized.py @@ -271,7 +271,7 @@ def set_test_runner(name): def detect_runner(): """ Guess which test runner we're using by traversing the stack and looking for the first matching module. This *should* be reasonably safe, as - it's done during test disocvery where the test runner should be the + it's done during test discovery where the test runner should be the stack frame immediately outside. """ if _test_runner_override is not None: return _test_runner_override From 3cf092bb872257efb47a814ab3fb8e0bfd8f61b4 Mon Sep 17 00:00:00 2001 From: Warren Weckesser Date: Thu, 19 Dec 2019 04:48:34 -0500 Subject: [PATCH 0058/4713] DOC: linalg: Include information about scipy.linalg. (#14988) * DOC: Add links to scipy linalg fuctions and compare numpy.linalg vs scipy.linalg. --- doc/source/reference/routines.linalg.rst | 12 ++++++ numpy/linalg/linalg.py | 50 +++++++++++++++++++++++- 2 files changed, 60 insertions(+), 2 deletions(-) diff --git a/doc/source/reference/routines.linalg.rst b/doc/source/reference/routines.linalg.rst index d42e77ad8e2d..86e168b262a2 100644 --- a/doc/source/reference/routines.linalg.rst +++ b/doc/source/reference/routines.linalg.rst @@ -18,6 +18,18 @@ or specify the processor architecture. .. _OpenBLAS: https://www.openblas.net/ .. _threadpoolctl: https://github.com/joblib/threadpoolctl +The SciPy library also contains a `~scipy.linalg` submodule, and there is +overlap in the functionality provided by the SciPy and NumPy submodules. SciPy +contains functions not found in `numpy.linalg`, such as functions related to +LU decomposition and the Schur decomposition, multiple ways of calculating the +pseudoinverse, and matrix transcendentals such as the matrix logarithm. Some +functions that exist in both have augmented functionality in `scipy.linalg`. +For example, `scipy.linalg.eig` can take a second matrix argument for solving +generalized eigenvalue problems. Some functions in NumPy, however, have more +flexible broadcasting options. For example, `numpy.linalg.solve` can handle +"stacked" arrays, while `scipy.linalg.solve` accepts only a single square +array as its first argument. + .. currentmodule:: numpy Matrix and vector products diff --git a/numpy/linalg/linalg.py b/numpy/linalg/linalg.py index 6249a57c263a..3d2d1705744b 100644 --- a/numpy/linalg/linalg.py +++ b/numpy/linalg/linalg.py @@ -345,6 +345,10 @@ def solve(a, b): LinAlgError If `a` is singular or not square. + See Also + -------- + scipy.linalg.solve : Similar function in SciPy. + Notes ----- @@ -502,6 +506,10 @@ def inv(a): LinAlgError If `a` is not square or inversion fails. + See Also + -------- + scipy.linalg.inv : Similar function in SciPy. + Notes ----- @@ -700,6 +708,14 @@ def cholesky(a): If the decomposition fails, for example, if `a` is not positive-definite. + See Also + -------- + scipy.linalg.cholesky : Similar function in SciPy. + scipy.linalg.cholesky_banded : Cholesky decompose a banded Hermitian + positive-definite matrix. + scipy.linalg.cho_factor : Cholesky decomposition of a matrix, to use in + `scipy.linalg.cho_solve`. + Notes ----- @@ -812,6 +828,11 @@ def qr(a, mode='reduced'): LinAlgError If factoring fails. + See Also + -------- + scipy.linalg.qr : Similar function in SciPy. + scipy.linalg.rq : Compute RQ decomposition of a matrix. + Notes ----- This is an interface to the LAPACK routines ``dgeqrf``, ``zgeqrf``, @@ -1004,6 +1025,7 @@ def eigvals(a): (conjugate symmetric) arrays. eigh : eigenvalues and eigenvectors of real symmetric or complex Hermitian (conjugate symmetric) arrays. + scipy.linalg.eigvals : Similar function in SciPy. Notes ----- @@ -1105,6 +1127,7 @@ def eigvalsh(a, UPLO='L'): eigvals : eigenvalues of general real or complex arrays. eig : eigenvalues and right eigenvectors of general real or complex arrays. + scipy.linalg.eigvalsh : Similar function in SciPy. Notes ----- @@ -1203,12 +1226,12 @@ def eig(a): See Also -------- eigvals : eigenvalues of a non-symmetric array. - eigh : eigenvalues and eigenvectors of a real symmetric or complex Hermitian (conjugate symmetric) array. - eigvalsh : eigenvalues of a real symmetric or complex Hermitian (conjugate symmetric) array. + scipy.linalg.eig : Similar function in SciPy (but also solves the + generalized eigenvalue problem). Notes ----- @@ -1355,6 +1378,8 @@ def eigh(a, UPLO='L'): (conjugate symmetric) arrays. eig : eigenvalues and right eigenvectors for non-symmetric arrays. eigvals : eigenvalues of non-symmetric arrays. + scipy.linalg.eigh : Similar function in SciPy (but also solves the + generalized eigenvalue problem). Notes ----- @@ -1506,6 +1531,11 @@ def svd(a, full_matrices=True, compute_uv=True, hermitian=False): LinAlgError If SVD computation does not converge. + See Also + -------- + scipy.linalg.svd : Similar function in SciPy. + scipy.linalg.svdvals : Compute singular values of a matrix. + Notes ----- @@ -1917,6 +1947,13 @@ def pinv(a, rcond=1e-15, hermitian=False): LinAlgError If the SVD computation does not converge. + See Also + -------- + scipy.linalg.pinv : Similar function in SciPy. + scipy.linalg.pinv2 : Similar function in SciPy (SVD-based). + scipy.linalg.pinvh : Compute the (Moore-Penrose) pseudo-inverse of a + Hermitian matrix. + Notes ----- The pseudo-inverse of a matrix A, denoted :math:`A^+`, is @@ -2079,6 +2116,7 @@ def det(a): -------- slogdet : Another way to represent the determinant, more suitable for large matrices where underflow/overflow may occur. + scipy.linalg.det : Similar function in SciPy. Notes ----- @@ -2179,6 +2217,10 @@ def lstsq(a, b, rcond="warn"): LinAlgError If computation does not converge. + See Also + -------- + scipy.linalg.lstsq : Similar function in SciPy. + Notes ----- If `b` is a matrix, then all array results are returned as matrices. @@ -2353,6 +2395,10 @@ def norm(x, ord=None, axis=None, keepdims=False): n : float or ndarray Norm of the matrix or vector(s). + See Also + -------- + scipy.linalg.norm : Similar function in SciPy. + Notes ----- For values of ``ord < 1``, the result is, strictly speaking, not a From f78510c9b0b2297533dedbb41fe6a510a66ed6b2 Mon Sep 17 00:00:00 2001 From: Warren Weckesser Date: Thu, 19 Dec 2019 19:14:45 -0500 Subject: [PATCH 0059/4713] MAINT: CI: Clean up .travis.yml The comments in .travis.yml say # After changing this file, check it on: # http://lint.travis-ci.org/ When I do that, I get the following from the linter: ``` [warn] on root: unknown key "stage" (Comprehensive tests) [info] on root: the key matrix is an alias for jobs, using jobs [info] on root: missing os, using the default "linux" ``` This commit fixes the issues reported in those messages. --- .travis.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 4afac959d7a8..5ee27edb7527 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,6 +2,7 @@ # http://lint.travis-ci.org/ language: python group: travis_latest +os: linux dist: xenial # Travis whitelists the installable packages, additions can be requested @@ -18,8 +19,6 @@ cache: directories: - $HOME/.cache/pip -stage: Comprehensive tests - stages: # Do the style check and a single test job, don't proceed if it fails - name: Initial tests @@ -37,13 +36,14 @@ env: iFWt9Ka92CaqYdU7nqfWp9VImSndPmssjmCXJ1v1IjZPAM\ ahp7Qnm0rWRmA0z9SomuRUQOJQ6s684vU=" -matrix: +jobs: include: # Do all python versions without environment variables set - stage: Initial tests python: 3.8 - - python: 3.6 + - stage: Comprehensive tests + python: 3.6 - python: 3.7 - python: 3.6 From 437f2ede2d4fed1229256f8afdd7d2662b775e8b Mon Sep 17 00:00:00 2001 From: Kevin Sheppard Date: Fri, 20 Dec 2019 13:33:48 +0000 Subject: [PATCH 0060/4713] DOC: Correct choice signature Add shuffle to signature --- numpy/random/_generator.pyx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/numpy/random/_generator.pyx b/numpy/random/_generator.pyx index d76cde44c811..df4d68927a05 100644 --- a/numpy/random/_generator.pyx +++ b/numpy/random/_generator.pyx @@ -629,7 +629,7 @@ cdef class Generator: @cython.wraparound(True) def choice(self, a, size=None, replace=True, p=None, axis=0, bint shuffle=True): """ - choice(a, size=None, replace=True, p=None, axis=0): + choice(a, size=None, replace=True, p=None, axis=0, shuffle=True): Generates a random sample from a given 1-D array From 7beb24e8ab3a53f9af0ab049e31ec30deecfcf25 Mon Sep 17 00:00:00 2001 From: Tyler Reddy Date: Fri, 20 Dec 2019 16:18:03 -0700 Subject: [PATCH 0061/4713] TST: shippable build efficiency * try to avoid a redundant build of NumPy by Shippable CI; use "-n" flag to runtests.py to encourage use of installed NumPy instead of trying to rebuild * prefix pip installs with "python" to avoid common issues using pip installs --- shippable.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/shippable.yml b/shippable.yml index b5ce1775129e..f64cb9937cec 100644 --- a/shippable.yml +++ b/shippable.yml @@ -27,29 +27,29 @@ build: - target=$(python tools/openblas_support.py) - sudo cp -r "${target}"/64/lib/* /usr/lib - sudo cp "${target}"/64/include/* /usr/include - - pip install --upgrade pip + - python -m pip install --upgrade pip # we will pay the ~13 minute cost of compiling Cython only when a new # version is scraped in by pip; otherwise, use the cached # wheel shippable places on Amazon S3 after we build it once - - pip install -r test_requirements.txt --cache-dir=/root/.cache/pip/wheels/$SHIPPABLE_PYTHON_VERSION + - python -m pip install -r test_requirements.txt --cache-dir=/root/.cache/pip/wheels/$SHIPPABLE_PYTHON_VERSION # install pytest-xdist to leverage a second core # for unit tests - - pip install pytest-xdist + - python -m pip install pytest-xdist # build and test numpy - export PATH=$PATH:$SHIPPABLE_REPO_DIR # build first and adjust PATH so f2py is found in scripts dir # use > 1 core for build sometimes slows down a fair bit, # other times modestly speeds up, so avoid for now - - pip install . + - python -m pip install . - extra_directories=($SHIPPABLE_REPO_DIR/build/*scripts*) - extra_path=$(printf "%s:" "${extra_directories[@]}") - export PATH="${extra_path}${PATH}" # check OpenBLAS version - python tools/openblas_support.py --check_version 0.3.7 # run the test suite - - python runtests.py --debug-info --show-build-log -- -rsx --junit-xml=$SHIPPABLE_REPO_DIR/shippable/testresults/tests.xml -n 2 --durations=10 + - python runtests.py -n --debug-info --show-build-log -- -rsx --junit-xml=$SHIPPABLE_REPO_DIR/shippable/testresults/tests.xml -n 2 --durations=10 cache: true cache_dir_list: From 97a83887da945e884a684b10f8c59eb710b1a26b Mon Sep 17 00:00:00 2001 From: Marten van Kerkwijk Date: Fri, 20 Dec 2019 19:25:25 -0500 Subject: [PATCH 0062/4713] BUG: ensure reduction output matches input along non-reduction axes. Previously, things like `np.add.reduce(np.ones((3, 3)), axis=0, out=np.empty(1))` worked, even though the output should have shape (3,). --- numpy/core/src/umath/reduction.c | 23 +++++++++++++++++++++-- numpy/core/tests/test_ufunc.py | 17 +++++++++++++++++ 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/numpy/core/src/umath/reduction.c b/numpy/core/src/umath/reduction.c index 4ce8d8ab7436..79c3027551cc 100644 --- a/numpy/core/src/umath/reduction.c +++ b/numpy/core/src/umath/reduction.c @@ -84,10 +84,12 @@ allocate_reduce_result(PyArrayObject *arr, const npy_bool *axis_flags, * The return value is a view into 'out'. */ static PyArrayObject * -conform_reduce_result(int ndim, const npy_bool *axis_flags, +conform_reduce_result(PyArrayObject *in, const npy_bool *axis_flags, PyArrayObject *out, int keepdims, const char *funcname, int need_copy) { + int ndim = PyArray_NDIM(in); + npy_intp *shape_in = PyArray_DIMS(in); npy_intp strides[NPY_MAXDIMS], shape[NPY_MAXDIMS]; npy_intp *strides_out = PyArray_STRIDES(out); npy_intp *shape_out = PyArray_DIMS(out); @@ -118,6 +120,16 @@ conform_reduce_result(int ndim, const npy_bool *axis_flags, return NULL; } } + else { + if (shape_out[idim] != shape_in[idim]) { + PyErr_Format(PyExc_ValueError, + "output parameter for reduction operation %s " + "has a non-reduction dimension not equal to " + "the input one.", funcname); + return NULL; + } + } + } Py_INCREF(out); @@ -138,6 +150,13 @@ conform_reduce_result(int ndim, const npy_bool *axis_flags, "does not have enough dimensions", funcname); return NULL; } + if (shape_out[idim_out] != shape_in[idim]) { + PyErr_Format(PyExc_ValueError, + "output parameter for reduction operation %s " + "has a non-reduction dimension not equal to " + "the input one.", funcname); + return NULL; + } strides[idim] = strides_out[idim_out]; shape[idim] = shape_out[idim_out]; ++idim_out; @@ -240,7 +259,7 @@ PyArray_CreateReduceResult(PyArrayObject *operand, PyArrayObject *out, /* Steal the dtype reference */ Py_XDECREF(dtype); - result = conform_reduce_result(PyArray_NDIM(operand), axis_flags, + result = conform_reduce_result(operand, axis_flags, out, keepdims, funcname, need_copy); } diff --git a/numpy/core/tests/test_ufunc.py b/numpy/core/tests/test_ufunc.py index 7109de77685c..4c04aceb3861 100644 --- a/numpy/core/tests/test_ufunc.py +++ b/numpy/core/tests/test_ufunc.py @@ -1888,6 +1888,23 @@ def test_reduce_noncontig_output(self): assert_equal(y_base[1,:], y_base_copy[1,:]) assert_equal(y_base[3,:], y_base_copy[3,:]) + @pytest.mark.parametrize('output_shape', + [(), (1,), (1, 1), (1, 3), (4, 3)]) + @pytest.mark.parametrize('f_reduce', [np.add.reduce, np.minimum.reduce]) + def test_reduce_wrong_dimension_output(self, f_reduce, output_shape): + # Test that we're not incorrectly broadcasting dimensions. + # See gh-15144 (failed for np.add.reduce previously). + a = np.arange(12.).reshape(4, 3) + out = np.empty(output_shape, a.dtype) + assert_raises(ValueError, f_reduce, a, axis=0, out=out) + if output_shape != (1, 3): + assert_raises(ValueError, f_reduce, a, axis=0, out=out, + keepdims=True) + else: + check = f_reduce(a, axis=0, out=out, keepdims=True) + assert_(check is out) + assert_array_equal(check, f_reduce(a, axis=0, keepdims=True)) + def test_no_doc_string(self): # gh-9337 assert_('\n' not in umt.inner1d_no_doc.__doc__) From b473fc6af5c51b8c3e80ef1cf081ef910a5b8634 Mon Sep 17 00:00:00 2001 From: Pauli Virtanen Date: Sun, 15 Dec 2019 13:48:05 +0200 Subject: [PATCH 0063/4713] CI: add openblas64_ downloading to openblas_support.py --- tools/openblas_support.py | 47 ++++++++++++++++++++++++++++----------- 1 file changed, 34 insertions(+), 13 deletions(-) diff --git a/tools/openblas_support.py b/tools/openblas_support.py index 964adce6e43c..1a63d18b49a3 100644 --- a/tools/openblas_support.py +++ b/tools/openblas_support.py @@ -40,7 +40,15 @@ def get_arch(): assert ret in ARCHITECTURES return ret -def download_openblas(target, arch): +def get_ilp64(): + if os.environ.get("NPY_USE_BLAS_ILP64", "0") == "0": + return None + if IS_32BIT: + raise RuntimeError("NPY_USE_BLAS_ILP64 set on 32-bit arch") + return "64_" + +def download_openblas(target, arch, ilp64): + fnsuffix = {None: "", "64_": "64_"}[ilp64] filename = '' if arch == 'arm': # ARMv8 OpenBLAS built using script available here: @@ -48,7 +56,7 @@ def download_openblas(target, arch): # build done on GCC compile farm machine named gcc115 # tarball uploaded manually to an unshared Dropbox location filename = ('https://www.dropbox.com/s/vdeckao4omss187/' - 'openblas-{}-armv8.tar.gz?dl=1'.format(OPENBLAS_V)) + 'openblas{}-{}-armv8.tar.gz?dl=1'.format(fnsuffix, OPENBLAS_V)) typ = 'tar.gz' elif arch == 'ppc64': # build script for POWER8 OpenBLAS available here: @@ -56,25 +64,25 @@ def download_openblas(target, arch): # built on GCC compile farm machine named gcc112 # manually uploaded tarball to an unshared Dropbox location filename = ('https://www.dropbox.com/s/yt0d2j86x1j8nh1/' - 'openblas-{}-ppc64le-power8.tar.gz?dl=1'.format(OPENBLAS_V)) + 'openblas{}-{}-ppc64le-power8.tar.gz?dl=1'.format(fnsuffix, OPENBLAS_V)) typ = 'tar.gz' elif arch == 'darwin': - filename = '{0}/openblas-{1}-macosx_10_9_x86_64-gf_1becaaa.tar.gz'.format( - RACKSPACE, OPENBLAS_LONG) + filename = '{0}/openblas{1}-{2}-macosx_10_9_x86_64-gf_1becaaa.tar.gz'.format( + RACKSPACE, fnsuffix, OPENBLAS_LONG) typ = 'tar.gz' elif arch == 'windows': if IS_32BIT: suffix = 'win32-gcc_7_1_0.zip' else: suffix = 'win_amd64-gcc_7_1_0.zip' - filename = '{0}/openblas-{1}-{2}'.format(RACKSPACE, OPENBLAS_LONG, suffix) + filename = '{0}/openblas{1}-{2}-{3}'.format(RACKSPACE, fnsuffix, OPENBLAS_LONG, suffix) typ = 'zip' elif arch == 'x86': if IS_32BIT: suffix = 'manylinux1_i686.tar.gz' else: suffix = 'manylinux1_x86_64.tar.gz' - filename = '{0}/openblas-{1}-{2}'.format(RACKSPACE, OPENBLAS_LONG, suffix) + filename = '{0}/openblas{1}-{2}-{3}'.format(RACKSPACE, fnsuffix, OPENBLAS_LONG, suffix) typ = 'tar.gz' if not filename: return None @@ -86,7 +94,7 @@ def download_openblas(target, arch): return None return typ -def setup_openblas(arch=get_arch()): +def setup_openblas(arch=get_arch(), ilp64=get_ilp64()): ''' Download and setup an openblas library for building. If successful, the configuration script will find it automatically. @@ -100,7 +108,7 @@ def setup_openblas(arch=get_arch()): _, tmp = mkstemp() if not arch: raise ValueError('unknown architecture') - typ = download_openblas(tmp, arch) + typ = download_openblas(tmp, arch, ilp64) if not typ: return '' if arch == 'windows': @@ -180,11 +188,17 @@ def test_setup(arches): ''' Make sure all the downloadable files exist and can be opened ''' - for arch in arches: + def items(): + for arch in arches: + yield arch, None + if arch in ('x86', 'darwin', 'windows'): + yield arch, '64_' + + for arch, ilp64 in items(): if arch == '': continue try: - target = setup_openblas(arch) + target = setup_openblas(arch, ilp64) except: print('Could not setup %s' % arch) raise @@ -192,7 +206,7 @@ def test_setup(arches): raise RuntimeError('Could not setup %s' % arch) print(target) -def test_version(expected_version): +def test_version(expected_version, ilp64=get_ilp64()): """ Assert that expected OpenBLAS version is actually available via NumPy @@ -201,12 +215,19 @@ def test_version(expected_version): import ctypes dll = ctypes.CDLL(numpy.core._multiarray_umath.__file__) - get_config = dll.openblas_get_config + if ilp64 == "64_": + get_config = dll.openblas_get_config64_ + else: + get_config = dll.openblas_get_config get_config.restype=ctypes.c_char_p res = get_config() print('OpenBLAS get_config returned', str(res)) check_str = b'OpenBLAS %s' % expected_version[0].encode() assert check_str in res + if ilp64: + assert b"USE64BITINT" in res + else: + assert b"USE64BITINT" not in res if __name__ == '__main__': import argparse From f554976fc5c342aa0e9e1fcdc59050325b18a68c Mon Sep 17 00:00:00 2001 From: Pauli Virtanen Date: Sun, 15 Dec 2019 13:48:21 +0200 Subject: [PATCH 0064/4713] CI: add travis openblas64_ target --- .travis.yml | 12 +++++++++++- tools/travis-before-install.sh | 11 ++++++++--- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 5ee27edb7527..316ab62e2942 100644 --- a/.travis.yml +++ b/.travis.yml @@ -75,7 +75,17 @@ jobs: - USE_ASV=1 - python: 3.7 - env: NPY_RELAXED_STRIDES_CHECKING=0 + env: + - NPY_RELAXED_STRIDES_CHECKING=0 + # use custom symbol-suffixed openblas build, not system ATLAS + - DOWNLOAD_OPENBLAS=1 + - CHECK_BLAS=1 + - NPY_USE_BLAS_ILP64=1 + addons: + apt: + packages: + - gfortran + - eatmydata - python: 3.7 env: USE_WHEEL=1 NPY_RELAXED_STRIDES_DEBUG=1 diff --git a/tools/travis-before-install.sh b/tools/travis-before-install.sh index 072ad3bf6cd9..79ec2da4f78d 100755 --- a/tools/travis-before-install.sh +++ b/tools/travis-before-install.sh @@ -5,12 +5,17 @@ free -m df -h ulimit -a -if [ -n "$PPC64_LE" ]; then +if [ -n "$PPC64_LE" -o -n "$DOWNLOAD_OPENBLAS" ]; then pwd ls -ltrh target=$(python tools/openblas_support.py) - sudo cp -r $target/64/lib/* /usr/lib - sudo cp $target/64/include/* /usr/include + if [ -d "$target/usr/local" ]; then + sudo cp -r $target/usr/local/lib/* /usr/lib + sudo cp $target/usr/local/include/* /usr/include + else + sudo cp -r $target/64/lib/* /usr/lib + sudo cp $target/64/include/* /usr/include + fi fi mkdir builds From 4903971fce8fdd4dc38e66706432962a0a94e8d7 Mon Sep 17 00:00:00 2001 From: Pauli Virtanen Date: Sun, 15 Dec 2019 23:16:18 +0200 Subject: [PATCH 0065/4713] TST: linalg: add ilp64 lapack low-memory smoketest LAPACK lwork call does not require much memory, and can be used as a smoketest to whether LAPACK really uses 64-bit integers. --- numpy/linalg/tests/test_linalg.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/numpy/linalg/tests/test_linalg.py b/numpy/linalg/tests/test_linalg.py index bd3df1ca472d..ef05b595ea9d 100644 --- a/numpy/linalg/tests/test_linalg.py +++ b/numpy/linalg/tests/test_linalg.py @@ -2016,3 +2016,31 @@ def test_blas64_dot(): a[0,-1] = 1 c = np.dot(b, a) assert_equal(c[0,-1], 1) + + +@pytest.mark.xfail(not HAS_LAPACK64, + reason="Numpy not compiled with 64-bit BLAS/LAPACK") +def test_blas64_geqrf_lwork_smoketest(): + # Smoke test LAPACK geqrf lwork call with 64-bit integers + dtype = np.float64 + lapack_routine = np.linalg.lapack_lite.dgeqrf + + m = 2**32 + 1 + n = 2**32 + 1 + lda = m + + # Dummy arrays, not referenced by the lapack routine, so don't + # need to be of the right size + a = np.zeros([1, 1], dtype=dtype) + work = np.zeros([1], dtype=dtype) + tau = np.zeros([1], dtype=dtype) + + # Size query + results = lapack_routine(m, n, a, lda, tau, work, -1, 0) + assert_equal(results['info'], 0) + assert_equal(results['m'], m) + assert_equal(results['n'], m) + + # Should result to an integer of a reasonable size + lwork = int(work.item()) + assert_(2**32 < lwork < 2**42) From b1c8dd9979caf899e6e5c758faef27b8453c334a Mon Sep 17 00:00:00 2001 From: Pauli Virtanen Date: Mon, 16 Dec 2019 21:25:17 +0200 Subject: [PATCH 0066/4713] CI: use openblas64_ on azure windows --- azure-pipelines.yml | 2 ++ azure-steps-windows.yml | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 29fc6c614bc8..3a626eeaeef2 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -171,6 +171,8 @@ stages: PYTHON_ARCH: 'x64' TEST_MODE: full BITS: 64 + NPY_USE_BLAS_ILP64: '1' + OPENBLAS_SUFFIX: '64_' steps: - template: azure-steps-windows.yml - job: Linux_PyPy3 diff --git a/azure-steps-windows.yml b/azure-steps-windows.yml index 26d7a667d8cc..f17039455743 100644 --- a/azure-steps-windows.yml +++ b/azure-steps-windows.yml @@ -11,7 +11,7 @@ steps: - powershell: | $pyversion = python -c "from __future__ import print_function; import sys; print(sys.version.split()[0])" Write-Host "Python Version: $pyversion" - $target = "C:\\hostedtoolcache\\windows\\Python\\$pyversion\\$(PYTHON_ARCH)\\lib\\openblas.a" + $target = "C:\\hostedtoolcache\\windows\\Python\\$pyversion\\$(PYTHON_ARCH)\\lib\\openblas$env:OPENBLAS_SUFFIX.a" Write-Host "target path: $target" $openblas = python tools/openblas_support.py cp $openblas $target From 5bc0b498e02cb5a3737791c425c2c9681a7257c1 Mon Sep 17 00:00:00 2001 From: Pauli Virtanen Date: Tue, 17 Dec 2019 23:42:59 +0200 Subject: [PATCH 0067/4713] CI: add to Azure a MacOS ilp64 job --- azure-pipelines.yml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 3a626eeaeef2..d6ab4d80c5d9 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -65,13 +65,21 @@ stages: # azure config for mac os -- Microsoft has indicated # they will patch this issue vmImage: macOS-10.14 + strategy: + maxParallel: 2 + matrix: + Python36: + PYTHON_VERSION: '3.6' + Python36-ILP64: + PYTHON_VERSION: '3.6' + NPY_USE_BLAS_ILP64: '1' 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' + versionSpec: $(PYTHON_VERSION) addToPath: true architecture: 'x64' # NOTE: do we have a compelling reason to use older / newer From 2dbe8de7090b4a39a1f19b2c81c2d3b085b7b244 Mon Sep 17 00:00:00 2001 From: Pauli Virtanen Date: Tue, 17 Dec 2019 23:49:57 +0200 Subject: [PATCH 0068/4713] CI: use only one flag on travis for downloading openblas --- .travis.yml | 1 + tools/travis-before-install.sh | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 316ab62e2942..73106b4c1de6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -104,6 +104,7 @@ jobs: arch: ppc64le env: # use ppc64le OpenBLAS build, not system ATLAS + - DOWNLOAD_OPENBLAS=1 - ATLAS=None - python: 3.7 diff --git a/tools/travis-before-install.sh b/tools/travis-before-install.sh index 79ec2da4f78d..516d33053a76 100755 --- a/tools/travis-before-install.sh +++ b/tools/travis-before-install.sh @@ -5,7 +5,7 @@ free -m df -h ulimit -a -if [ -n "$PPC64_LE" -o -n "$DOWNLOAD_OPENBLAS" ]; then +if [ -n "$DOWNLOAD_OPENBLAS" ]; then pwd ls -ltrh target=$(python tools/openblas_support.py) From 49974bad2d11e3be31cb83f881ae09dd91b8dd25 Mon Sep 17 00:00:00 2001 From: Pauli Virtanen Date: Fri, 20 Dec 2019 13:33:46 +0200 Subject: [PATCH 0069/4713] MAINT: make openblas_support.py strip path prefix from archive contents Adapt CI scripts to this. --- azure-pipelines.yml | 10 +++--- shippable.yml | 5 +-- tools/openblas_support.py | 64 ++++++++++++++++++++++++++++------ tools/pypy-test.sh | 15 ++++---- tools/travis-before-install.sh | 9 ++--- 5 files changed, 72 insertions(+), 31 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index d6ab4d80c5d9..1851df71a1d6 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -40,8 +40,9 @@ stages: locale-gen fr_FR && update-locale && \ apt-get -y install gfortran-5 wget && \ target=\$(python3 tools/openblas_support.py) && \ - cp -r \$target/usr/local/lib/* /usr/lib && \ - cp \$target/usr/local/include/* /usr/include && \ + ls -lR \$target && \ + cp -r \$target/lib/* /usr/lib && \ + cp \$target/include/* /usr/include && \ python3 -m pip install --user --upgrade pip setuptools && \ python3 -m pip install --user -r test_requirements.txt && \ python3 -m pip install . && \ @@ -105,9 +106,10 @@ stages: # primarily on file size / name details - script: | target=$(python tools/openblas_support.py) + ls -lR $target # manually link to appropriate system paths - cp $target/usr/local/lib/* /usr/local/lib/ - cp $target/usr/local/include/* /usr/local/include/ + cp $target/lib/* /usr/local/lib/ + cp $target/include/* /usr/local/include/ displayName: 'install pre-built openblas' - script: python -m pip install --upgrade pip setuptools wheel displayName: 'Install tools' diff --git a/shippable.yml b/shippable.yml index f64cb9937cec..4313a6de2cf2 100644 --- a/shippable.yml +++ b/shippable.yml @@ -25,8 +25,9 @@ build: - sudo apt-get update - sudo apt-get install gcc gfortran - target=$(python tools/openblas_support.py) - - sudo cp -r "${target}"/64/lib/* /usr/lib - - sudo cp "${target}"/64/include/* /usr/include + - ls -lR "${target}" + - sudo cp -r "${target}"/lib/* /usr/lib + - sudo cp "${target}"/include/* /usr/include - python -m pip install --upgrade pip # we will pay the ~13 minute cost of compiling Cython only when a new diff --git a/tools/openblas_support.py b/tools/openblas_support.py index 1a63d18b49a3..4a210cfe1c71 100644 --- a/tools/openblas_support.py +++ b/tools/openblas_support.py @@ -1,6 +1,8 @@ from __future__ import division, absolute_import, print_function import os import sys +import glob +import shutil import textwrap import platform try: @@ -86,6 +88,7 @@ def download_openblas(target, arch, ilp64): typ = 'tar.gz' if not filename: return None + print("Downloading:", filename, file=sys.stderr) try: with open(target, 'wb') as fid: fid.write(urlopen(filename).read()) @@ -140,10 +143,33 @@ def unpack_targz(fname): if not os.path.exists(target): os.mkdir(target) with tarfile.open(fname, 'r') as zf: - # TODO: check that all the zf.getnames() files do not escape the - # extract directory (no leading '../', '/') - zf.extractall(target) - return target + # Strip common prefix from paths when unpacking + prefix = os.path.commonpath(zf.getnames()) + extract_tarfile_to(zf, target, prefix) + return target + +def extract_tarfile_to(tarfileobj, target_path, archive_path): + """Extract TarFile contents under archive_path/ to target_path/""" + + target_path = os.path.abspath(target_path) + + def get_members(): + for member in tarfileobj.getmembers(): + if archive_path: + norm_path = os.path.normpath(member.name) + if norm_path.startswith(archive_path + os.path.sep): + member.name = norm_path[len(archive_path)+1:] + else: + continue + + dst_path = os.path.abspath(os.path.join(target_path, member.name)) + if os.path.commonpath([target_path, dst_path]) != target_path: + # Path not under target_path, probably contains ../ + continue + + yield member + + tarfileobj.extractall(target_path, members=get_members()) def make_init(dirname): ''' @@ -197,14 +223,30 @@ def items(): for arch, ilp64 in items(): if arch == '': continue + + target = None try: - target = setup_openblas(arch, ilp64) - except: - print('Could not setup %s' % arch) - raise - if not target: - raise RuntimeError('Could not setup %s' % arch) - print(target) + try: + target = setup_openblas(arch, ilp64) + except: + print('Could not setup %s' % arch) + raise + if not target: + raise RuntimeError('Could not setup %s' % arch) + print(target) + if arch == 'windows': + if not target.endswith('.a'): + raise RuntimeError("Not .a extracted!") + else: + files = glob.glob(os.path.join(target, "lib", "*.a")) + if not files: + raise RuntimeError("No lib/*.a unpacked!") + finally: + if target is not None: + if os.path.isfile(target): + os.unlink(target) + else: + shutil.rmtree(target) def test_version(expected_version, ilp64=get_ilp64()): """ diff --git a/tools/pypy-test.sh b/tools/pypy-test.sh index f4d56ba1a741..33a97ad17e03 100755 --- a/tools/pypy-test.sh +++ b/tools/pypy-test.sh @@ -11,19 +11,20 @@ sudo apt-get -yq install libatlas-base-dev liblapack-dev gfortran-5 F77=gfortran-5 F90=gfortran-5 \ # Download the proper OpenBLAS x64 precompiled library -target=$(python tools/openblas_support.py) +target=$(python3 tools/openblas_support.py) +ls -lR "$target" echo getting OpenBLAS into $target -export LD_LIBRARY_PATH=$target/usr/local/lib -export LIB=$target/usr/local/lib -export INCLUDE=$target/usr/local/include +export LD_LIBRARY_PATH=$target/lib +export LIB=$target/lib +export INCLUDE=$target/include # Use a site.cfg to build with local openblas cat << EOF > site.cfg [openblas] libraries = openblas -library_dirs = $target/usr/local/lib:$LIB -include_dirs = $target/usr/local/lib:$LIB -runtime_library_dirs = $target/usr/local/lib +library_dirs = $target/lib:$LIB +include_dirs = $target/lib:$LIB +runtime_library_dirs = $target/lib EOF echo getting PyPy 3.6 nightly diff --git a/tools/travis-before-install.sh b/tools/travis-before-install.sh index 516d33053a76..9f8b66a4740c 100755 --- a/tools/travis-before-install.sh +++ b/tools/travis-before-install.sh @@ -9,13 +9,8 @@ if [ -n "$DOWNLOAD_OPENBLAS" ]; then pwd ls -ltrh target=$(python tools/openblas_support.py) - if [ -d "$target/usr/local" ]; then - sudo cp -r $target/usr/local/lib/* /usr/lib - sudo cp $target/usr/local/include/* /usr/include - else - sudo cp -r $target/64/lib/* /usr/lib - sudo cp $target/64/include/* /usr/include - fi + sudo cp -r $target/lib/* /usr/lib + sudo cp $target/include/* /usr/include fi mkdir builds From 316fef7cc4933fbb01e46e5e15b875b0b879a06b Mon Sep 17 00:00:00 2001 From: Charles Harris Date: Sun, 22 Dec 2019 10:08:00 -0700 Subject: [PATCH 0070/4713] REL: Update master after NumPy 1.18.0 release. - Update .mailmap. - Update release notes. - Create changelog - Remove duplicate release note entry. - Fix release note path in pavement. [skip ci] --- .mailmap | 13 +- doc/changelog/1.18.0-changelog.rst | 533 ++++++++++++++++++ .../upcoming_changes/15106.new_feature.rst | 4 - doc/source/release/1.18.0-notes.rst | 144 +++-- pavement.py | 2 +- 5 files changed, 632 insertions(+), 64 deletions(-) create mode 100644 doc/changelog/1.18.0-changelog.rst delete mode 100644 doc/release/upcoming_changes/15106.new_feature.rst diff --git a/.mailmap b/.mailmap index 9d7aaa3c43dc..836f2f81c4d5 100644 --- a/.mailmap +++ b/.mailmap @@ -63,6 +63,7 @@ Christopher Hanley chanley Christoph Gohlke cgholke Christoph Gohlke cgohlke Christoph Gohlke Christolph Gohlke +Colin Snyder <47012605+colinsnyder@users.noreply.github.com> colinsnyder <47012605+colinsnyder@users.noreply.github.com> Daniel B Allan danielballan Daniel da Silva Daniel da Silva Daniel da Silva Daniel da Silva @@ -126,6 +127,7 @@ Jérémie du Boisberranger jeremiedbb <34657 Jerome Kelleher jeromekelleher Johannes Hampp euronion <42553970+euronion@users.noreply.github.com> Johannes Schönberger Johannes Schönberger +Johann Faouzi johann.faouzi John Darbyshire <24256554+attack68@users.noreply.github.com> attack68 <24256554+attack68@users.noreply.github.com> Joseph Fox-Rabinovitz Joseph Fox-Rabinovitz Joseph Fox-Rabinovitz Joseph Fox-Rabinovitz @@ -135,6 +137,7 @@ Julian Taylor Julian Taylor Julian Taylor Julien Lhermitte Julien Lhermitte Julien Schueller jschueller +Justus Magin keewis Kai Striega kai Kai Striega kai-striega Kai Striega kai-striega @@ -149,6 +152,8 @@ Lars Buitinck Lars Buitinck Lars Grüter Lars G Luis Pedro Coelho Luis Pedro Coelho Luke Zoltan Kelley lzkelley +Magdalena Proszewska mpro +Magdalena Proszewska mproszewska <38814059+mproszewska@users.noreply.github.com> Manoj Kumar MechCoder Mark DePristo markdepristo Mark Weissman m-d-w @@ -157,6 +162,7 @@ Mark Wiebe Mark Wiebe Mark Wiebe Mark Wiebe Mark Wiebe Mark Wiebe Martin Goodson martingoodson +Martin Reinecke mreineck Martin Teichmann Martin Teichmann Martino Sorbaro martinosorb Mattheus Ueckermann empeeu @@ -232,7 +238,12 @@ Wojtek Ruszczewski wrwrwr Yuji Kanagawa kngwyu Yury Kirienko kirienko Zixu Zhao ZZhaoTireless -Ziyan Zhou Ziyan +Ziyan Zhou Ziyan +Zieji Pohz jpoh +Zieji Pohz zjpoh +Zieji Pohz Zijie (ZJ) Poh <8103276+zjpoh@users.noreply.github.com> +Zolisa Bleki zoj613 <44142765+zoj613@users.noreply.github.com> +Zolisa Bleki RedRuM <44142765+zoj613@users.noreply.github.com> luzpaz luz.paz luzpaz luzpaz spacescientist spacescientist diff --git a/doc/changelog/1.18.0-changelog.rst b/doc/changelog/1.18.0-changelog.rst new file mode 100644 index 000000000000..b86b3614ad3a --- /dev/null +++ b/doc/changelog/1.18.0-changelog.rst @@ -0,0 +1,533 @@ + +Contributors +============ + +A total of 114 people contributed to this release. People with a "+" by their +names contributed a patch for the first time. + +* Abhinav Sagar +* Alex Henrie + +* Alexander Jung + +* Allan Haldane +* Andrea Pattori +* Andrew Liu + +* Anis Ladram + +* Anne Bonner + +* Antoine Dechaume + +* Aryan Naraghi + +* Bastian Eichenberger + +* Brian Wignall + +* Brigitta Sipocz +* CakeWithSteak + +* Charles Harris +* Chris Barker +* Chris Burr + +* Chris Markiewicz + +* Christoph Gohlke +* Christopher Whelan +* Colin Snyder +* Dan Allan +* Daniel Ching +* David Stansby + +* David Zwicker + +* Dieter Werthmüller +* Disconnect3d + +* Dmytro + +* Doug Davis + +* Eric Larson +* Eric Wieser +* Esben Haabendal + +* Eugene Prilepin + +* Felix Divo + +* Gary Gurlaskie +* Gina + +* Giuseppe Cuccu + +* Grzegorz Bokota + +* Guanqun Lu + +* Guilherme Leobas + +* Guillaume Horel +* Géraud Le Falher + +* Hameer Abbasi +* Harmon +* Hiroyuki V. Yamazaki +* Huang, Guangtai + +* Hugo + +* Hyeonguk Ryu + +* Ilhan Polat + +* Isaac Virshup +* Jack J. Woehr + +* Jack Woehr + +* Jackie Leng +* Jaime Fernandez +* Jeff Hale + +* Johann Faouzi + +* Jon Dufresne + +* Joseph Fox-Rabinovitz +* Joseph R. Fox-Rabinovitz + +* João Marcos Gris + +* Justus Magin + +* Jérémie du Boisberranger +* Kai Striega +* Kevin Sheppard +* Kexuan Sun +* Kmol Yuan + +* Kriti Singh +* Larry Bradley + +* Lars Grueter +* Luis Pedro Coelho +* MSeifert04 +* Magdalena Proszewska + +* Manny + +* Mark Harfouche +* Martin Reinecke +* Martin Thoma +* Matt Haberland + +* Matt McCormick + +* Matthias Bussonnier +* Matti Picus +* Max Bolingbroke + +* Maxwell Aladago + +* Michael Hudson-Doyle + +* Oleksandr Pavlyk +* Omar Merghany + +* Pauli Virtanen +* Peter Andreas Entschev +* Peter Bell +* Peter Cock + +* Pradeep Reddy Raamana + +* Qiming Sun + +* Raghuveer Devulapalli +* Ralf Gommers +* Samesh + +* Samesh Lakhotia + +* Sebastian Berg +* Sergei Lebedev +* Seth Troisi + +* Siddhesh Poyarekar + +* Simon + +* Simon Notley + +* Stefan van der Walt +* Stephan Hoyer +* Steve Stagg +* Thomas A Caswell +* Thomas Kluyver +* Tim Hoffmann + +* Tirth Patel + +* Tyler Reddy +* Vladimir Pershin + +* Warren Weckesser +* Yadong Zhang + +* Zieji Pohz + +* Zolisa Bleki + + +Pull requests merged +==================== + +A total of 406 pull requests were merged for this release. + +* `#9301 `__: DOC: added note to docstring of numpy.savez +* `#10151 `__: BUG: Numpy scalar types sometimes have the same name +* `#12129 `__: DOC: Improve axes shift description and example in np.tensordot +* `#12205 `__: MAINT: avoid relying on `np.generic.__name__` in `np.dtype.name` +* `#12284 `__: ENH: supply our version of numpy.pxd, requires cython>=0.29 +* `#12633 `__: BUG: General fixes to f2py reference counts (dereferencing) +* `#12658 `__: BUG: NaT now sorts to ends of arrays +* `#12828 `__: DOC: Updates to nditer usage instructions +* `#13003 `__: BUG: Do not crash on recursive `.dtype` attribute lookup. +* `#13368 `__: ENH: Use AVX for float32 implementation of np.sin & np.cos +* `#13605 `__: DEP: Deprecate silent ignoring of bad data in fromfile/fromstring +* `#13610 `__: ENH: Always produce a consistent shape in the result of `argwhere` +* `#13673 `__: DOC: array(obj, dtype=dt) can downcast +* `#13698 `__: DOC: Document ma.filled behavior with non-scalar fill_value +* `#13710 `__: DOC: Add note to irfft-like functions about the default sizes +* `#13739 `__: BUG: Don't produce undefined behavior for a << b if b >= bitsof(a) +* `#13766 `__: MAINT: Update NEP template. +* `#13794 `__: ENH: random: Add the multivariate hypergeometric distribution. +* `#13799 `__: DOC: Fix unrendered links +* `#13812 `__: MAINT: Rewrite Floyd algorithm +* `#13825 `__: DOC: Add missing macros to C-API documentation +* `#13829 `__: ENH: Add axis argument to random.permutation and random.shuffle +* `#13847 `__: DOC: Adds documentation of functions exposed in numpy namespace +* `#13860 `__: BUG: Refcount fixes +* `#13871 `__: MAINT: Ensure array_dealloc does not modify refcount of self +* `#13874 `__: MAINT: Prepare master for 1.18.0 development. +* `#13876 `__: MAINT,BUG,DOC: Fix errors in _add_newdocs +* `#13880 `__: MAINT: Remove an unnessary backslash between two string literals +* `#13881 `__: MAINT: Update pavement to use python3 in shell commands. +* `#13882 `__: MAINT: Remove unnecessary backslashes (and replace others by... +* `#13883 `__: MAINT: Replace integers in places where booleans are expected +* `#13884 `__: DOC: Add missing parameter description for keepdims in MaskedArray +* `#13885 `__: ENH: use AVX for float32 and float64 implementation of sqrt,... +* `#13886 `__: DOC: reformat top-level release index +* `#13892 `__: DOC : Refactor Array API documentation -- Array Structure and... +* `#13895 `__: DOC: Fix typo in "make_mask" documentation +* `#13896 `__: MAINT: Delete unused _aliased_types.py +* `#13901 `__: BLD: Remove Trusty dist in Travis CI build +* `#13907 `__: BUG: Handle weird bytestrings in dtype() +* `#13908 `__: ENH: use towncrier to build the release note +* `#13913 `__: ENH: improve error message for ragged-array creation failure +* `#13914 `__: DOC: Update the description of byteswap +* `#13916 `__: BUG: i0 Bessel function regression on array-likes supporting... +* `#13920 `__: ENH, BUILD: refactor all OpenBLAS downloads into a single, testable... +* `#13922 `__: MAINT: Remove unnecessary parenthesis in numpy.ma.core +* `#13925 `__: MAINT: Fix wrong spelling of ufunc +* `#13926 `__: DOC: Remove explicit .next method calls with built-in next function... +* `#13928 `__: DOC: Don't override MaskedArray.view documentation with the one... +* `#13930 `__: BUG: Fix incorrect GIL release in array.nonzero +* `#13935 `__: MAINT: Warn if `_add_newdocs.py` is used to add docstrings to... +* `#13943 `__: MAINT: Revert #13876, "MAINT,BUG,DOC: Fix errors in _add_newdocs" +* `#13944 `__: MAINT,BUG,DOC: Fix errors in _add_newdocs +* `#13945 `__: DOC, MAINT: emphasize random API changes, remove Generator.randint +* `#13946 `__: DOC: Add a numpy-doc docstring to add_newdoc +* `#13947 `__: DOC: Fix rst rendering in data types +* `#13948 `__: DOC:Update the description of set_printoptions in quickstart... +* `#13950 `__: Fixing failure on Python 2.7 on Windows 7 +* `#13952 `__: Fix a typo related to the range of indices +* `#13959 `__: DOC: add space between words across lines +* `#13964 `__: BUG, DOC: add new recfunctions to `__all__` +* `#13967 `__: DOC: Change (old) range() to np.arange() +* `#13968 `__: DOC: improve np.sort docstring +* `#13970 `__: DOC: spellcheck numpy/doc/broadcasting.py +* `#13976 `__: MAINT, TST: remove test-installed-numpy.py +* `#13979 `__: DOC: Document array_function at a higher level. +* `#13985 `__: DOC: show workaround for backward compatibility +* `#13988 `__: DOC: Add a call for contribution paragraph to the readme +* `#13989 `__: BUG: Missing warnings import in polyutils +* `#13990 `__: BUILD: adapt "make version-check" to "make dist" +* `#13991 `__: DOC: emphasize need for matching numpy, git versions +* `#14002 `__: TST, MAINT, BUG: expand OpenBLAS version checking +* `#14004 `__: ENH: Chain exception for typed item assignment +* `#14005 `__: MAINT: Fix spelling error in npy_tempita kwarg +* `#14010 `__: DOC: Array API : Directory restructure and code cleanup +* `#14011 `__: [DOC] Remove unused/deprecated functions +* `#14022 `__: Update system_info.py +* `#14025 `__: DOC:Link between the two indexing documentation pages +* `#14026 `__: DOC: Update NumFOCUS subcommittee replacing Nathaniel with Sebastian +* `#14027 `__: DOC: update "Contributing to NumPy" with more activities/roles +* `#14028 `__: DOC: Improve quickstart documentation of new random Generator +* `#14030 `__: DEP: Speed up WarnOnWrite deprecation in buffer interface +* `#14032 `__: NEP: numpy.org website redesign +* `#14035 `__: DOC: Fix docstring of numpy.allclose regarding NaNs +* `#14036 `__: DEP: Raise warnings for deprecated functions PyArray_As1D, PyArray_As2D +* `#14039 `__: DEP: Remove np.rank which has been deprecated for more than 5... +* `#14048 `__: BUG, TEST: Adding validation test suite to validate float32 exp +* `#14051 `__: ENH,DEP: Allow multiple axes in expand_dims +* `#14053 `__: ENH: add pyproject.toml +* `#14060 `__: DOC: Update cversions.py links and wording +* `#14062 `__: DOC, BUILD: cleanups and fix (again) 'make dist' +* `#14063 `__: BUG: Fix file-like object check when saving arrays +* `#14064 `__: DOC: Resolve bad references in Sphinx warnings +* `#14068 `__: MAINT: bump ARMv8 / POWER8 OpenBLAS in CI +* `#14069 `__: DOC: Emphasize the need to run tests when building from source +* `#14070 `__: DOC:Add example to clarify "numpy.save" behavior on already open... +* `#14072 `__: DEP: Deprecate full and economic modes for linalg.qr +* `#14073 `__: DOC: Doc release +* `#14074 `__: BUG: fix build issue on icc 2016 +* `#14076 `__: TST: Add 3.8-dev to travisCI testing. +* `#14085 `__: DOC: Add blank line above doctest for intersect1d +* `#14086 `__: ENH: Propose standard policy for dropping support of old Python... +* `#14089 `__: DOC: Use `pip install .` where possible instead of calling setup.py +* `#14091 `__: MAINT: adjustments to test_ufunc_noncontigous +* `#14092 `__: MAINT: Improve NEP template +* `#14096 `__: DOC: fix documentation of i and j for tri. +* `#14097 `__: MAINT: Lazy import testing on python >=3.7 +* `#14100 `__: DEP: Deprecate PyArray_FromDimsAndDataAndDescr, PyArray_FromDims +* `#14101 `__: MAINT: Clearer error message while padding with stat_length=0 +* `#14106 `__: MAINT: remove duplicate variable assignments +* `#14108 `__: BUG: initialize variable that is passed by pointer +* `#14110 `__: DOC: fix typo in c-api/array.rst doc +* `#14121 `__: BUG: Add gcd/lcm definitions to npy_math.h +* `#14122 `__: MAINT: Mark umath accuracy test xfail. +* `#14124 `__: MAINT: Use equality instead of identity check with literal +* `#14130 `__: MAINT: Fix small typo in quickstart docs +* `#14134 `__: DOC, MAINT: Update master after 1.17.0 release. +* `#14141 `__: ENH: add c-imported modules for freeze analysis in np.random +* `#14143 `__: BUG: Fix DeprecationWarning in python 3.8 +* `#14144 `__: BUG: Remove stray print that causes a SystemError on python 3.7... +* `#14145 `__: BUG: Remove the broken clip wrapper +* `#14152 `__: BUG: avx2_scalef_ps must be static +* `#14153 `__: TST: Allow fuss in testing strided/non-strided exp/log loops +* `#14170 `__: NEP: Proposal for __duckarray__ protocol +* `#14171 `__: BUG: Make advanced indexing result on read-only subclass writeable +* `#14178 `__: TST: Clean up of test_pocketfft.py +* `#14181 `__: DEP: Deprecate np.alen +* `#14185 `__: MAINT: Workaround for Intel compiler bug leading to failing test +* `#14190 `__: DOC: Fix hermitian argument docs in `svd` +* `#14195 `__: MAINT: Fix a docstring typo. +* `#14196 `__: DOC: Fix links in `/.github/CONTRIBUTING.md`. +* `#14197 `__: ENH: Multivariate normal speedups +* `#14203 `__: MAINT: Improve mismatch message of np.testing.assert_array_equal +* `#14204 `__: DOC,MAINT: Move towncrier files and fixup categories +* `#14207 `__: BUG: Fixed default BitGenerator name +* `#14209 `__: BUG: Fix uint-overflow if padding with linear_ramp and negative... +* `#14216 `__: ENH: Enable huge pages in all Linux builds +* `#14217 `__: BUG: Fix leak in the f2py-generated module init and `PyMem_Del`... +* `#14219 `__: DOC: new nan_to_num keywords are from 1.17 onwards +* `#14223 `__: TST: Add tests for deprecated C functions (PyArray_As1D, PyArray_As1D) +* `#14224 `__: DOC: mention `take_along_axis` in `choose` +* `#14227 `__: ENH: Parse complex number from string +* `#14231 `__: DOC: update or remove outdated sourceforge links +* `#14234 `__: MAINT: Better error message for norm +* `#14235 `__: DOC: add backlinks to numpy.org +* `#14240 `__: BUG: Don't fail when lexsorting some empty arrays. +* `#14241 `__: BUG: Fix segfault in `random.permutation(x)` when x is a string. +* `#14245 `__: Doc: fix a typo in NEP21 +* `#14249 `__: DOC: set status of NEP 28 (website redesign) to Accepted +* `#14250 `__: BLD: MAINT: change default behavior of build flag appending. +* `#14252 `__: BUG: Fixes StopIteration error from 'np.genfromtext' for empty... +* `#14255 `__: BUG: fix inconsistent axes ordering for axis in function `unique` +* `#14256 `__: DEP: Deprecate load/dump functions in favour of pickle methods +* `#14257 `__: MAINT: Update NEP-30 +* `#14259 `__: DEP: Deprecate arrayprint formatting functions +* `#14266 `__: DOC: remove scipy.org from the breadcrumb formattiong +* `#14270 `__: BUG: Fix formatting error in exception message +* `#14272 `__: DOC: Address typos in dispatch docs +* `#14279 `__: BUG: Fix ZeroDivisionError for zero length arrays in pocketfft. +* `#14290 `__: BUG: Fix misuse of .names and .fields in various places +* `#14291 `__: TST, BUG: Use python3.6-dbg. +* `#14295 `__: BUG: core: Handle large negative np.int64 args in binary_repr. +* `#14298 `__: BUG: Fix numpy.random bug in platform detection +* `#14303 `__: MAINT: random: Match type of SeedSequence.pool_size to DEFAULT_POOL_SIZE. +* `#14310 `__: Bug: Fix behavior of structured_to_unstructured on non-trivial... +* `#14311 `__: DOC: add two commas, move one word +* `#14313 `__: DOC: Clarify rules about broadcasting when empty arrays are involved. +* `#14321 `__: TST, MAINT: bump to OpenBLAS 0.3.7 stable +* `#14325 `__: DEP: numpy.testing.rand +* `#14335 `__: DEP: Deprecate class `SafeEval` +* `#14341 `__: BUG: revert detecting and raising error on ragged arrays +* `#14342 `__: DOC: Improve documentation of `isscalar`. +* `#14349 `__: MAINT: Fix bloated mismatch error percentage in array comparisons. +* `#14351 `__: DOC: Fix a minor typo in dispatch documentation. +* `#14352 `__: MAINT: Remove redundant deprecation checks +* `#14353 `__: MAINT: polynomial: Add an N-d vander implementation used under... +* `#14355 `__: DOC: clarify that PytestTester is non-public +* `#14356 `__: DOC: support and require sphinx>=2.2 +* `#14360 `__: DOC: random: fix doc linking, was referencing private submodules. +* `#14364 `__: MAINT: Fixes for prospective Python 3.10 and 4.0 +* `#14365 `__: DOC: lib: Add more explanation of the weighted average calculation. +* `#14368 `__: MAINT: Avoid BytesWarning in PyArray_DescrConverter() +* `#14369 `__: MAINT: Post NumPy 1.17.1 update. +* `#14370 `__: DOC: Fixed dtype docs for var, nanvar. +* `#14372 `__: DOC: Document project as Python 3 only with a trove classifier +* `#14378 `__: BUILD: move all test dependencies to ./test_requirements.txt +* `#14381 `__: BUG: lib: Fix histogram problem with signed integer arrays. +* `#14385 `__: REL: Update master after NumPy 1.16.5 release. +* `#14387 `__: BUG: test, fix regression in converting to ctypes +* `#14389 `__: NEP: Add initial draft of NEP-31: Context-local and global overrides... +* `#14390 `__: DOC: document numpy/doc update process +* `#14392 `__: DOC: update np.around docstring with note about floating-point... +* `#14393 `__: BUG: view with fieldless dtype should raise if itemsize != 0 +* `#14395 `__: DOC: fix issue with __new__ usage in subclassing doc. +* `#14398 `__: DOC: Fix release notes table of contents +* `#14399 `__: NEP 32: Remove the financial functions from NumPy +* `#14404 `__: BLD: Update RELEASE_WALKTHROUGH and cythonize. +* `#14407 `__: Bump pytest from 5.1.1 to 5.1.2 +* `#14408 `__: TST: Remove build job since we now use Dependabot +* `#14410 `__: BLD: Only allow using Cython module when cythonizing. +* `#14411 `__: TST: Add dependabot config file. +* `#14416 `__: BUG: Fix format statement associated with AttributeError. +* `#14417 `__: BUG: Fix aradixsort indirect indexing. +* `#14426 `__: DOC: add the reference to 'printoptions' +* `#14429 `__: BUG: Do not show Override module in private error classes. +* `#14444 `__: DOC: Make implementation bullet points consistent in NEP 29 +* `#14447 `__: MAINT: Clarify policy language in NEP-29. +* `#14448 `__: REL: Update master after 1.17.2 release. +* `#14452 `__: MAINT: clean up pocketfft modules inside numpy.fft namespace +* `#14453 `__: BLD: remove generated Cython files from sdist +* `#14454 `__: MAINT: add test to prevent new public-looking modules being added +* `#14458 `__: BUG: random.hypergeometic assumes npy_long is npy_int64, hangs... +* `#14459 `__: ENH: Print the amount of memory that would be used by a failed... +* `#14460 `__: MAINT: use test_requirements.txt in tox and shippable, ship it... +* `#14464 `__: BUG: add a specialized loop for boolean matmul +* `#14469 `__: BUG: Fix _ctypes class circular reference. (#13808) +* `#14472 `__: BUG: core: Fix the str function of the rational dtype. +* `#14475 `__: DOC: add timedelta64 signature +* `#14477 `__: MAINT: Extract raising of MemoryError to a helper function +* `#14483 `__: BUG,MAINT: Some fixes and minor cleanup based on clang analysis +* `#14484 `__: MAINT: Add `NPY_UNUSED` and `const` qualified suggested by clang +* `#14485 `__: MAINT: Silence integer comparison build warnings in assert statements +* `#14486 `__: MAINT: distutils: Add newline at the end of printed warnings. +* `#14490 `__: BUG: random: Revert gh-14458 and refix gh-14557. +* `#14493 `__: DOC: Fix reference NPY_ARRAY_OWNDATA instead of NPY_OWNDATA. +* `#14495 `__: ENH: Allow NPY_PKG_CONFIG_PATH environment variable override +* `#14498 `__: MAINT: remove the entropy c-extension module +* `#14499 `__: DOC: Add backslashes so PyUFunc_FromFuncAndDataAndSignatureAndIdentity... +* `#14500 `__: DOC: Fix a minor typo in changelog readme +* `#14501 `__: BUG: Fix randint when range is 2**32 +* `#14503 `__: DOC: tweak np.round docstring to clarify floating-point error +* `#14508 `__: DOC: Add warning to NPV function +* `#14510 `__: API: Do not return None from recfunctions.drop_fields +* `#14511 `__: BUG: Fix flatten_dtype so that nested 0-field structs are flattened... +* `#14514 `__: DOC: Build release notes during CircleCI step +* `#14518 `__: BUILD: Hide platform configuration probe behind --debug-configure +* `#14520 `__: Mention that split() returns views into the original array +* `#14521 `__: MAINT: Simplify lookfor function +* `#14523 `__: MAINT: random: Remove a few duplicated C function prototypes. +* `#14525 `__: BUILD, MAINT: run tests with verbose for PyPY, also do not leak... +* `#14526 `__: BUG: fix release snippet failures caught only after merging +* `#14527 `__: BLD: add warn-error option, adds -Werror to compiler +* `#14531 `__: BUG: random: Create a legacy implementation of random.binomial. +* `#14534 `__: MAINT: remove unused functions, rearrange headers (from CC=clang) +* `#14535 `__: DOC: Fix a bit of code in 'Beyond the Basics' C API user guide. +* `#14536 `__: MAINT: Cleanup old_defines in DOC +* `#14540 `__: DOC: Added missing versionadded to diff(prepend) +* `#14543 `__: BUG: Avoid ctypes in Generators +* `#14545 `__: Changing ImportWarning to DeprecationWarning +* `#14548 `__: MAINT: handle case where GIT_VERSION is empty string +* `#14554 `__: MAINT: core: Remove duplicated inner loop ee->e from log, exp,... +* `#14555 `__: DOC: clarify input types in basics.io.genfromtxt.rst +* `#14557 `__: DOC: remove note about Pocketfft license file (non-existing here). +* `#14558 `__: DOC: Fix code that generates the table in the 'Casting Rules'... +* `#14562 `__: MAINT: don't install partial numpy.random C/Cython API. +* `#14564 `__: TST: ensure coercion tables aren't printed on failing public... +* `#14567 `__: DEP: remove deprecated (and private) numpy.testing submodules. +* `#14568 `__: BLD, DOC: fix gh-14518, add release note +* `#14570 `__: BUG: importing build_src breaks setuptools monkeypatch for msvc14 +* `#14572 `__: DOC: Note runtests.py `-- -s` method to use pytests `-s` +* `#14573 `__: DOC: update submodule docstrings, remove info.py files +* `#14576 `__: DOC: Document the NPY_SCALARKIND values as C variables. +* `#14582 `__: MAINT: Bump pytest from 5.1.2 to 5.1.3 +* `#14583 `__: DEP: remove deprecated select behaviour +* `#14585 `__: BUG: Add missing check for 0-sized array in ravel_multi_index +* `#14586 `__: BUG: dtype refcount cleanups +* `#14587 `__: DOC: Fix a minor typo in changelog entry +* `#14592 `__: MAINT: Fix typo: remoge → remove +* `#14595 `__: DOC: Change the promotion table checkmark to 'Y'. +* `#14596 `__: DEP: Complete deprecation of invalid array/memory order +* `#14598 `__: DOC: Add to doc that interp cannot contain NaN +* `#14600 `__: NEP: Accept NEP 32. +* `#14601 `__: NEP: Fix discrepancies in NEPs +* `#14603 `__: NEP: Only list "Active" NEPs under "Meta-NEPs" +* `#14604 `__: API: restructure and document numpy.random C-API +* `#14605 `__: BUG: properly define PyArray_DescrCheck{,Exact} +* `#14607 `__: MAINT: Remove duplicate files from .gitignore +* `#14608 `__: API: rearrange the cython files in numpy.random +* `#14614 `__: MAINT: Bump pytest from 5.1.3 to 5.2.0 +* `#14615 `__: MAINT: Add "MAINT" tag to dependabot commit msg +* `#14616 `__: DOC: Updated sphinx directive formatting +* `#14620 `__: DEP: Finish deprecation of non-integer `num` in linspace +* `#14621 `__: DOC: s/OR/AND/ in np.logical_and docstring +* `#14623 `__: DOC: misleading np.sinc() documentation +* `#14629 `__: DOC: clarify residual in np.polyfit +* `#14630 `__: BUILD: change to build_src --verbose-cfg, runtests.py --debug-info +* `#14631 `__: BUG: always free clean_sep +* `#14634 `__: DOC: Create `class Extension` docstring and add it to documentation. +* `#14636 `__: DOC: add `printoptions` as a context manager to `set_printoptions` +* `#14639 `__: DOC: Fix typo in NEP 29 +* `#14643 `__: MAINT: Use scalar math power function directly +* `#14649 `__: DOC: Add IPython to dependencies needed to build docs. +* `#14652 `__: MAINT: Bump pytest-cov from 2.7.1 to 2.8.1 +* `#14653 `__: MAINT: Bump pytest from 5.2.0 to 5.2.1 +* `#14654 `__: MAINT: Bump pytz from 2019.2 to 2019.3 +* `#14656 `__: MAINT: Use `extract_unit` throughout datetime +* `#14657 `__: BUG: fix fromfile behavior when reading sub-array dtypes +* `#14662 `__: BUG: random: Use correct length when axis is given to shuffle. +* `#14669 `__: BUG: Do not rely on undefined behaviour to cast from float to... +* `#14674 `__: NEP: add default-dtype-object-deprecation nep 34 +* `#14681 `__: MAINT: Remove unused boolean negative/subtract loops +* `#14682 `__: DEP: ufunc `out` argument must be a tuple for multiple outputs +* `#14693 `__: BUG: Fix `np.einsum` errors on Power9 Linux and z/Linux +* `#14696 `__: DOC: Note release notes process changes on devdocs start page +* `#14699 `__: Doc warnings +* `#14705 `__: DOC: Switch Markdown link to RST in NEP 29 +* `#14709 `__: TST: Divide Azure CI Pipelines into stages. +* `#14710 `__: DEP: Finish the out kwarg deprecation for ufunc calls +* `#14711 `__: DOC: Removing mentions of appveyor +* `#14714 `__: BUG: Default start to 0 for timedelta arange +* `#14717 `__: API: NaT (arg)min/max behavior +* `#14718 `__: API: Forbid Q<->m safe casting +* `#14720 `__: DEP: deprecate financial functions. +* `#14721 `__: DOC: Move newsfragment to correct folder +* `#14723 `__: DOC: cleaning up examples in maskedarray.generic +* `#14725 `__: MAINT: umath: Change error message for unsupported bool subtraction. +* `#14730 `__: ENH: Add complex number support for fromfile +* `#14732 `__: TST: run refguide-check on rst files in doc/* +* `#14734 `__: DOC: Edit NEP procedure for better discussion +* `#14736 `__: DOC: Post 1.17.3 release update. +* `#14737 `__: NEP: Accept NEP 29 as final +* `#14738 `__: BUG: Don't narrow intp to int when producing error messages +* `#14742 `__: DOC: lib: Fix deprecation markup in financial function docstrings. +* `#14743 `__: DOC: Change from HTTP to HTTPS +* `#14745 `__: BUG: clear only attribute errors in get_attr_string.h::maybe_get_attr +* `#14762 `__: MAINT: doc: Remove doc/newdtype_example/ +* `#14763 `__: Reword cautionary note about dtype.descr +* `#14769 `__: BUG: fix integer size confusion in handling array's ndmin argument +* `#14771 `__: TST, BUILD: add a gcc 4.8 run on ubuntu 18.04 +* `#14775 `__: Update CLASSIFIERS with python 3.8 support +* `#14777 `__: BUG: random: biased samples from integers() with 8 or 16 bit... +* `#14782 `__: DOC: Add release note about changed random variate stream from... +* `#14786 `__: DOC: Make changes to NEP procedure +* `#14790 `__: DOC: random: Remove redundant 'See Also' entry in 'uniform' docstring. +* `#14791 `__: MAINT: Minor typo fix +* `#14792 `__: MAINT: Bump pytest from 5.2.1 to 5.2.2 +* `#14793 `__: DOC: Adjust NEP-31 to new template. +* `#14794 `__: DEP: issue deprecation warning when creating ragged array (NEP... +* `#14798 `__: NEP: move 'NEP 29 random' from Accepted to Final +* `#14799 `__: DOC: Add take_along_axis to the see also section in argmin, argmax... +* `#14800 `__: ENH: change object-array comparisons to prefer OO->O unfuncs +* `#14805 `__: TST: Don't construct Fraction instances from numpy scalars +* `#14814 `__: Rename helper functions to not use the word rank +* `#14820 `__: MAINT: Use templating to merge float loops +* `#14826 `__: BUILD: ignore more build.log warnings +* `#14827 `__: BLD: Prevent -flto from optimising long double representation... +* `#14829 `__: BUG: raise ValueError for empty arrays passed to _pyarray_correlate +* `#14830 `__: MAINT: move buffer.h -> npy_buffer.h to avoid conflicts +* `#14836 `__: MAINT: Bump cython from 0.29.13 to 0.29.14 +* `#14841 `__: ENH: add isinf, isnan, fmin, fmax loops for datetime64, timedelta64 +* `#14842 `__: BLD: add 'apt update' to shippable +* `#14845 `__: MAINT: revert gh-14800, which gave precedence to OO->O over OO->? +* `#14874 `__: REL: Update master after 1.17.4 release. +* `#14878 `__: BUILD: remove SSE2 flag from numpy.random builds +* `#14879 `__: DOC: Update NEP29 with Python3.8 informations. +* `#14881 `__: BUG: Remove builtins from __all__ +* `#14898 `__: MAINT: Delete and ignore generated files +* `#14899 `__: Update FUNDING.yml +* `#14901 `__: MAINT: Remove uses of scalar aliases +* `#14903 `__: NEP: move nep 34 to accepted +* `#14907 `__: TST: Add s390x to the TravisCI test matrix. +* `#14912 `__: DOC: Note FFT type promotion +* `#14914 `__: TST: Test with Python3.8 on Windows. +* `#14915 `__: TST: Update travis.yml +* `#14921 `__: TST: add no_tracing decorator to refcount-sensitive codepath... +* `#14926 `__: MAINT: Bump pytest from 5.2.2 to 5.2.4 +* `#14929 `__: BUG: Fix step returned by linspace when num=1 and endpoint=False +* `#14932 `__: DOC: Compare 'tolist' function to 'list' in example +* `#14935 `__: DOC: Clarify return type for default_rng +* `#14944 `__: MAINT: move numpy/random/examples -> numpy/random/_examples +* `#14947 `__: DOC: testing: Note handling of scalars in assert_array_equal... +* `#14948 `__: DOC, API: add random.__init__.pxd and document random.* functions +* `#14951 `__: DOC: Clean up examples of low-level random access +* `#14954 `__: TST. API: test using distributions.h via cffi +* `#14962 `__: TST: skip if cython is not available +* `#14967 `__: MAINT: Cleaned up mintypecode for Py3 +* `#14973 `__: DOC: fix docstring of np.linalg.norm +* `#14974 `__: MAINT: Added Python3.8 branch to dll lib discovery on Windows +* `#14976 `__: DEV: update asv.conf.json +* `#14978 `__: MAINT: Bump pytest from 5.2.4 to 5.3.0 +* `#14982 `__: MAINT: Fix typos +* `#14983 `__: REV: "ENH: Improved performance of PyArray_FromAny for sequences... +* `#14994 `__: BUG: warn when saving dtype with metadata +* `#14996 `__: DEP: Deprecate the axis argument to masked_rows and masked_cols +* `#15004 `__: MAINT: Fix long name of PCG64 +* `#15007 `__: DOC, API: improve the C-API/Cython documentation and interfaces... +* `#15009 `__: DOC: Fix typo in numpy.loadtxt and numpy.genfromtxt documentation +* `#15012 `__: ENH: allow using symbol-suffixed 64-bit BLAS/LAPACK for numpy.dot... +* `#15014 `__: DOC: add a more useful comment to compat.py3k.py +* `#15019 `__: DOC: lib: Use a clearer example of ddof in the notes of the cov... +* `#15021 `__: TST: machinery for tests requiring large memory + lapack64 smoketest +* `#15023 `__: MAINT: Only copy input array in _replace_nan() if there are nans... +* `#15025 `__: MAINT: Bump pytest from 5.3.0 to 5.3.1 +* `#15027 `__: REV: "ENH: Improved performance of PyArray_FromAny for sequences... +* `#15031 `__: REL: Prepare for 1.18 branch +* `#15032 `__: MAINT: Cleaned up mintypecode for Py3 (pt. 2) +* `#15036 `__: BUG: Fix refcounting in ufunc object loops +* `#15039 `__: BUG: Exceptions tracebacks are dropped +* `#15053 `__: REV: Revert "Merge pull request #14794 from mattip/nep-0034-impl" +* `#15058 `__: API, DOC: change names to multivariate_hypergeometric, improve docs +* `#15059 `__: REL: Prepare for NumPy 1.18.0 release. +* `#15109 `__: TST: Check requires_memory immediately before the test +* `#15111 `__: ENH: Add support to sort timedelta64 `NaT` to end of the array +* `#15112 `__: MAINT: follow-up cleanup for blas64 PR +* `#15113 `__: ENH: f2py: add --f2cmap option for specifying the name of .f2py_f2cmap +* `#15114 `__: ENH: add support for ILP64 OpenBLAS (without symbol suffix) +* `#15146 `__: REL: Prepare for 1.18.0 release. diff --git a/doc/release/upcoming_changes/15106.new_feature.rst b/doc/release/upcoming_changes/15106.new_feature.rst deleted file mode 100644 index 9f1d0b247909..000000000000 --- a/doc/release/upcoming_changes/15106.new_feature.rst +++ /dev/null @@ -1,4 +0,0 @@ -Add ``--f2cmap`` option to F2PY -------------------------------- -Allow specifying a file to load Fortran-to-C type map -customizations from. diff --git a/doc/source/release/1.18.0-notes.rst b/doc/source/release/1.18.0-notes.rst index dc0c4ce84759..851e35b8888a 100644 --- a/doc/source/release/1.18.0-notes.rst +++ b/doc/source/release/1.18.0-notes.rst @@ -1,14 +1,33 @@ +.. currentmodule:: numpy + ================================ NumPy NumPy 1.18.0 Release Notes ================================ +In addition to the usual bug fixes, this NumPy release cleans up and documents +the new random C-API, expires a large number of old deprecations, and improves +the appearance of the documentation. The Python versions supported are 3.5-3.8. +This is the last NumPy release series that will support Python 3.5. + +Downstream developers should use Cython >= 0.29.14 for Python 3.8 support and +OpenBLAS >= 3.7 to avoid problems on the Skylake +architecture. + + +Highlights +========== + +* The C-API for ``numpy.random`` has been defined and documented. +* Basic infrastructure for linking with 64 bit BLAS and LAPACK libraries. +* Many documentation improvements. + New functions ============= -Multivariate hypergeometric distribution added to `numpy.random` ----------------------------------------------------------------- -The method `multivariate_hypergeometric` has been added to the class +Multivariate hypergeometric distribution added to ``numpy.random`` +------------------------------------------------------------------ +The method ``multivariate_hypergeometric`` has been added to the class `numpy.random.Generator`. This method generates random variates from the multivariate hypergeometric probability distribution. (`gh-13794 `__) @@ -17,15 +36,14 @@ the multivariate hypergeometric probability distribution. Deprecations ============ -`np.fromfile` and `np.fromstring` will error on bad data --------------------------------------------------------- +``np.fromfile`` and ``np.fromstring`` will error on bad data +------------------------------------------------------------ -In future numpy releases, the functions `np.fromfile` and `np.fromstring` +In future numpy releases, the functions ``np.fromfile`` and ``np.fromstring`` will throw an error when parsing bad data. This will now give a ``DeprecationWarning`` where previously partial or even invalid data was silently returned. This deprecation also affects -the C defined functions c:func:`PyArray_FromString`` and -c:func:`PyArray_FromFile` +the C defined functions ``PyArray_FromString`` and ``PyArray_FromFile`` (`gh-13605 `__) Deprecate non-scalar arrays as fill values in ``ma.fill_value`` @@ -35,29 +53,29 @@ since the logic to broadcast the fill value to the array is fragile, especially when slicing. (`gh-13698 `__) -Deprecate `PyArray_As1D`, `PyArray_As2D` ----------------------------------------- -`PyArray_As1D`, `PyArray_As2D` are deprecated, use -`PyArray_AsCArray` instead +Deprecate ``PyArray_As1D``, ``PyArray_As2D`` +-------------------------------------------- +``PyArray_As1D``, ``PyArray_As2D`` are deprecated, use +``PyArray_AsCArray`` instead (`gh-14036 `__) -Deprecate `np.alen` -------------------- -`np.alen` was deprecated. Use `len` instead. +Deprecate ``np.alen`` +--------------------- +``np.alen`` was deprecated. Use ``len`` instead. (`gh-14181 `__) Deprecate the financial functions --------------------------------- In accordance with `NEP-32 `_, -the functions `fv`, `ipmt`, `irr`, `mirr`, `nper`, `npv`, `pmt`, `ppmt`, -`pv` and `rate` are deprecated, and will be removed from NumPy 1.20. -The replacement for these functions is the Python package +the financial functions ``fv`` ``ipmt``, ``irr``, ``mirr``, ``nper``, +``npv``, ``pmt``, ``ppmt``, ``pv`` and ``rate`` are deprecated, and will be +removed from NumPy 1.20.The replacement for these functions is the Python package `numpy-financial `_. (`gh-14720 `__) -The ``axis`` argument to `numpy.ma.mask_cols` and `numpy.ma.mask_row` is deprecated ------------------------------------------------------------------------------------ +The ``axis`` argument to ``numpy.ma.mask_cols`` and ``numpy.ma.mask_row`` is deprecated +--------------------------------------------------------------------------------------- This argument was always ignored. (`gh-14996 `__) @@ -89,8 +107,10 @@ Expired deprecations * ``arrayprint.FloatFormat``, ``arrayprint.LongFloatFormat`` has been removed, use ``FloatingFormat`` instead + * ``arrayprint.ComplexFormat``, ``arrayprint.LongComplexFormat`` has been removed, use ``ComplexFloatingFormat`` instead + * ``arrayprint.StructureFormat`` has been removed, use ``StructureVoidFormat`` instead (`gh-14259 `__) @@ -99,22 +119,22 @@ Expired deprecations and has been replaced by ``np.random.rand``. (`gh-14325 `__) -* Class ``SafeEval`` in ``numpy/lib/utils.py`` has been removed. This was deprecated in NumPy 1.10. - Use ``np.safe_eval`` instead. +* Class ``SafeEval`` in ``numpy/lib/utils.py`` has been removed. + This was deprecated in NumPy 1.10. Use ``np.safe_eval`` instead. (`gh-14335 `__) * Remove deprecated support for boolean and empty condition lists in - `numpy.select` + ``np.select`` (`gh-14583 `__) * Array order only accepts 'C', 'F', 'A', and 'K'. More permissive options were deprecated in NumPy 1.11. (`gh-14596 `__) -* np.linspace param num must be an integer. This was deprecated in NumPy 1.12. +* np.linspace parameter ``num`` must be an integer. Deprecated in NumPy 1.12. (`gh-14620 `__) -* UFuncs with multiple outputs must use a tuple for the `out` kwarg. This +* UFuncs with multiple outputs must use a tuple for the ``out`` kwarg. This finishes a deprecation started in NumPy 1.10. (`gh-14682 `__) @@ -151,7 +171,6 @@ converting the empty recarray to None ``np.can_cast(np.uint64, np.timedelta64, casting='safe')`` is now ``False`` --------------------------------------------------------------------------- - Previously this was ``True`` - however, this was inconsistent with ``uint64`` not being safely castable to ``int64``, and resulting in strange type resolution. @@ -159,9 +178,9 @@ resolution. If this impacts your code, cast ``uint64`` to ``int64`` first. (`gh-14718 `__) -Changed random variate stream from `numpy.random.Generator.integers` --------------------------------------------------------------------- -There was a bug in `numpy.random.Generator.integers` that caused biased +Changed random variate stream from ``numpy.random.Generator.integers`` +---------------------------------------------------------------------- +There was a bug in ``numpy.random.Generator.integers`` that caused biased sampling of 8 and 16 bit integer types. Fixing that bug has changed the output stream from what it was in previous releases. (`gh-14777 `__) @@ -171,20 +190,21 @@ Add more ufunc loops for ``datetime64``, ``timedelta64`` ``np.datetime('NaT')`` should behave more like ``float('Nan')``. Add needed infrastructure so ``np.isinf(a)`` and ``np.isnan(a)`` will run on ``datetime64`` and ``timedelta64`` dtypes. Also added specific loops for -`numpy.fmin` and `numpy.fmax` that mask ``NaT``. This may require adjustment to user- -facing code. Specifically, code that either disallowed the calls to -`numpy.isinf` or `numpy.isnan` or checked that they raised an exception will -require adaptation, and code that mistakenly called `numpy.fmax` and -`numpy.fmin` instead of `numpy.maximum` or `numpy.minimum` respectively will -requre adjustment. This also affects `numpy.nanmax` and `numpy.nanmin`. +``numpy.fmin`` and ``numpy.fmax`` that mask ``NaT``. This may require +adjustment to user- facing code. Specifically, code that either disallowed the +calls to ``numpy.isinf`` or ``numpy.isnan`` or checked that they raised an +exception will require adaptation, and code that mistakenly called +``numpy.fmax`` and ``numpy.fmin`` instead of ``numpy.maximum`` or +``numpy.minimum`` respectively will requre adjustment. This also affects +``numpy.nanmax`` and ``numpy.nanmin``. (`gh-14841 `__) C API changes ============= -PyDataType_ISUNSIZED(descr) now returns False for structured datatypes ----------------------------------------------------------------------- +``PyDataType_ISUNSIZED(descr)`` now returns False for structured datatypes +-------------------------------------------------------------------------- Previously this returned True for any datatype of itemsize 0, but now this returns false for the non-flexible datatype with itemsize 0, ``np.dtype([])``. (`gh-14393 `__) @@ -193,15 +213,14 @@ returns false for the non-flexible datatype with itemsize 0, ``np.dtype([])``. New Features ============ - Add our own ``*.pxd`` cython import file --------------------------------------------- -Added a ``numpy/__init__.pxd`` file. It will be used for `cimport numpy` +---------------------------------------- +Added a ``numpy/__init__.pxd`` file. It will be used for ``cimport numpy`` (`gh-12284 `__) A tuple of axes can now be input to ``expand_dims`` --------------------------------------------------- -The `numpy.expand_dims` ``axis`` keyword can now accept a tuple of +The ``numpy.expand_dims`` ``axis`` keyword can now accept a tuple of axes. Previously, ``axis`` was required to be an integer. (`gh-14051 `__) @@ -209,6 +228,14 @@ Support for 64-bit OpenBLAS --------------------------- Added support for 64-bit (ILP64) OpenBLAS. See ``site.cfg.example`` for details. +(`gh-15012 `__) + +Add ``--f2cmap`` option to F2PY +------------------------------- +Allow specifying a file to load Fortran-to-C type map +customizations from. +(`gh-15113 `__) + Improvements ============ @@ -226,7 +253,7 @@ These types now always print with a unique ``__name__``. ``argwhere`` now produces a consistent result on 0d arrays ---------------------------------------------------------- -On N-d arrays, `numpy.argwhere` now always produces an array of shape +On N-d arrays, ``numpy.argwhere`` now always produces an array of shape ``(n_non_zero, arr.ndim)``, even when ``arr.ndim == 0``. Previously, the last axis would have a dimension of 1 in this case. (`gh-13610 `__) @@ -239,10 +266,10 @@ can only shuffle an array along the first axis; they now have a new argument ``axis`` which allows shuffle along a specified axis. (`gh-13829 `__) -``method`` keyword argument for `np.random.multivariate_normal` ---------------------------------------------------------------- +``method`` keyword argument for ``np.random.multivariate_normal`` +----------------------------------------------------------------- A ``method`` keyword argument is now available for -`np.random.multivariate_normal` with possible values +``np.random.multivariate_normal`` with possible values ``{'svd', 'eigh', 'cholesky'}``. To use it, write ``np.random.multivariate_normal(..., method=)``. (`gh-14197 `__) @@ -252,21 +279,21 @@ Add complex number support for ``numpy.fromstring`` Now ``numpy.fromstring`` can read complex numbers. (`gh-14227 `__) -`numpy.unique` has consistent axes order (except the chosen one) when ``axis`` is not None ------------------------------------------------------------------------------------------- -Using ``moveaxis`` instead of ``swapaxes`` in `numpy.unique`, so that the ordering of axes +``numpy.unique`` has consistent axes order when ``axis`` is not None +-------------------------------------------------------------------- +Using ``moveaxis`` instead of ``swapaxes`` in ``numpy.unique``, so that the ordering of axes except the axis in arguments will not be broken. (`gh-14255 `__) -`numpy.matmul` with boolean output now converts to boolean values ------------------------------------------------------------------ -Calling `numpy.matmul` where the output is a boolean array would fill the array +``numpy.matmul`` with boolean output now converts to boolean values +------------------------------------------------------------------- +Calling ``numpy.matmul`` where the output is a boolean array would fill the array with uint8 equivalents of the result, rather than 0/1. Now it forces the output to 0 or 1 (``NPY_TRUE`` or ``NPY_FALSE``). (`gh-14464 `__) -`numpy.random.randint` produced incorrect value when the range was ``2**32`` ----------------------------------------------------------------------------- +``numpy.random.randint`` produced incorrect value when the range was ``2**32`` +------------------------------------------------------------------------------ The implementation introduced in 1.17.0 had an incorrect check when determining whether to use the 32-bit path or the full 64-bit path that incorrectly redirected random integer generation with a high - low @@ -289,6 +316,7 @@ automatically add the code if the compiler name has ``gcc`` in it. Changes ======= + ``NaT`` now sorts to the end of arrays -------------------------------------- ``NaT`` is now effectively treated as the largest integer for sorting @@ -305,14 +333,14 @@ for non-numeric types and ``ValueError`` for ``nan`` values. Warn when saving a dtype with metadata -------------------------------------- -A ``UserWarning`` will be emitted when saving an array via `numpy.save` with +A ``UserWarning`` will be emitted when saving an array via ``numpy.save`` with ``metadata``. Saving such an array may not preserve metadata, and if metadata is preserved, loading it will cause a ``ValueError``. This shortcoming in save and load will be addressed in a future release. (`gh-14142 `__) -`numpy.distutils`: append behavior changed for LDFLAGS and similar ------------------------------------------------------------------- +``numpy.distutils`` append behavior changed for LDFLAGS and similar +------------------------------------------------------------------- `numpy.distutils` has always overridden rather than appended to ``LDFLAGS`` and other similar such environment variables for compiling Fortran extensions. Now the default behavior has changed to appending - which is the expected behavior @@ -326,9 +354,9 @@ change in behavior would have affected the compile flags used. Remove ``numpy.random.entropy`` without a deprecation ----------------------------------------------------- -``numpy.random.entropy`` was added to the `numpy.random` namespace in 1.17.0. +``numpy.random.entropy`` was added to the ``numpy.random`` namespace in 1.17.0. It was meant to be a private c-extension module, but was exposed as public. -It has been replaced by `numpy.random.SeedSequence` so the module was +It has been replaced by ``numpy.random.SeedSequence`` so the module was completely removed. (`gh-14498 `__) diff --git a/pavement.py b/pavement.py index 3637bc66d8e7..889a552f6ea3 100644 --- a/pavement.py +++ b/pavement.py @@ -41,7 +41,7 @@ #----------------------------------- # Path to the release notes -RELEASE_NOTES = 'doc/release/1.18.0-notes.rst' +RELEASE_NOTES = 'doc/source/release/1.18.0-notes.rst' #------------------------------------------------------- From 483f570694d8bed245ce5391515ba4ee1a0202da Mon Sep 17 00:00:00 2001 From: Charles Harris Date: Sun, 22 Dec 2019 12:37:15 -0700 Subject: [PATCH 0071/4713] MAINT: Update pavement.py for towncrier. The update is needed so that the links generated by towncrier are converted in the README.md file generated for the github release documentation. The code is also simplified. [skip ci] --- doc/HOWTO_RELEASE.rst.txt | 5 ++- doc/source/release/1.18.0-notes.rst | 6 +-- pavement.py | 60 +++++++++++++++++------------ 3 files changed, 41 insertions(+), 30 deletions(-) diff --git a/doc/HOWTO_RELEASE.rst.txt b/doc/HOWTO_RELEASE.rst.txt index f0231293f267..99f6a0e40a8c 100644 --- a/doc/HOWTO_RELEASE.rst.txt +++ b/doc/HOWTO_RELEASE.rst.txt @@ -106,9 +106,10 @@ You will need write permission for numpy-wheels in order to trigger wheel builds. - Python(s) from `python.org `_ or linux distro. -- cython +- cython (pip) - virtualenv (pip) - Paver (pip) +- pandoc `pandoc.org `_ or linux distro. - numpy-wheels ``_ (clone) @@ -379,7 +380,7 @@ Make the release ---------------- Build the changelog and notes for upload with:: - paver write_release_and_log + paver write_release Build and archive documentation diff --git a/doc/source/release/1.18.0-notes.rst b/doc/source/release/1.18.0-notes.rst index 851e35b8888a..9ca742eab4a9 100644 --- a/doc/source/release/1.18.0-notes.rst +++ b/doc/source/release/1.18.0-notes.rst @@ -366,9 +366,9 @@ Added two new configuration options. During the ``build_src`` subcommand, as part of configuring NumPy, the files ``_numpyconfig.h`` and ``config.h`` are created by probing support for various runtime functions and routines. Previously, the very verbose compiler output during this stage clouded more -important information. By default the output is silenced. Running ``runtests.py ---debug-info`` will add ``--verbose-cfg`` to the ``build_src`` subcommand, -which will restore the previous behaviour. +important information. By default the output is silenced. Running +``runtests.py --debug-info`` will add ``--verbose-cfg`` to the ``build_src`` +subcommand,which will restore the previous behaviour. Adding ``CFLAGS=-Werror`` to turn warnings into errors would trigger errors during the configuration. Now ``runtests.py --warn-error`` will add diff --git a/pavement.py b/pavement.py index 889a552f6ea3..352e375d23ec 100644 --- a/pavement.py +++ b/pavement.py @@ -182,6 +182,18 @@ def compute_sha256(idirs): def write_release_task(options, filename='README'): """Append hashes of release files to release notes. + This appends file hashes to the release notes ane creates + four README files of the result in various formats: + + - README.rst + - README.rst.gpg + - README.md + - README.md.gpg + + The md file are created using `pandoc` so that the links are + properly updated. The gpg files are kept separate, so that + the unsigned files may be edited before signing if needed. + Parameters ---------- options : @@ -192,46 +204,44 @@ def write_release_task(options, filename='README'): """ idirs = options.installers.installersdir - source = paver.path.path(RELEASE_NOTES) - target = paver.path.path(filename + '.rst') - if target.exists(): - target.remove() + notes = paver.path.path(RELEASE_NOTES) + rst_readme = paver.path.path(filename + '.rst') + md_readme = paver.path.path(filename + '.md') - tmp_target = paver.path.path(filename + '.md') - source.copy(tmp_target) + # append hashes + with open(rst_readme, 'w') as freadme: + with open(notes) as fnotes: + freadme.write(fnotes.read()) - with open(str(tmp_target), 'a') as ftarget: - ftarget.writelines(""" + freadme.writelines(""" Checksums ========= MD5 --- +:: """) - ftarget.writelines([' %s\n' % c for c in compute_md5(idirs)]) - ftarget.writelines(""" + freadme.writelines([f' {c}\n' for c in compute_md5(idirs)]) + freadme.writelines(""" SHA256 ------ +:: """) - ftarget.writelines([' %s\n' % c for c in compute_sha256(idirs)]) + freadme.writelines([f' {c}\n' for c in compute_sha256(idirs)]) - # Sign release - cmd = ['gpg', '--clearsign', '--armor'] + # generate md file using pandoc before signing + sh(f"pandoc -s -o {md_readme} {rst_readme}") + + # Sign files if hasattr(options, 'gpg_key'): - cmd += ['--default-key', options.gpg_key] - cmd += ['--output', str(target), str(tmp_target)] - subprocess.check_call(cmd) - print("signed %s" % (target,)) - - # Change PR links for github posting, don't sign this - # as the signing isn't markdown compatible. - with open(str(tmp_target), 'r') as ftarget: - mdtext = ftarget.read() - mdtext = re.sub(r'^\* `(\#[0-9]*).*?`__', r'* \1', mdtext, flags=re.M) - with open(str(tmp_target), 'w') as ftarget: - ftarget.write(mdtext) + cmd = f'gpg --clearsign --armor --default_key {options.gpg_key}' + else: + cmd = 'gpg --clearsign --armor' + + sh(cmd + f' --output {rst_readme}.gpg {rst_readme}') + sh(cmd + f' --output {md_readme}.gpg {md_readme}') @task From 2d289f097b4e1762b01eddbebe4e613e942d2ef7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Z=C3=A9=20Vin=C3=ADcius?= Date: Mon, 23 Dec 2019 13:50:01 +0800 Subject: [PATCH 0072/4713] DOC: update cholesky docstring regarding input checking --- numpy/linalg/linalg.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/numpy/linalg/linalg.py b/numpy/linalg/linalg.py index 3d2d1705744b..072670d5c3b6 100644 --- a/numpy/linalg/linalg.py +++ b/numpy/linalg/linalg.py @@ -687,8 +687,10 @@ def cholesky(a): Return the Cholesky decomposition, `L * L.H`, of the square matrix `a`, where `L` is lower-triangular and .H is the conjugate transpose operator (which is the ordinary transpose if `a` is real-valued). `a` must be - Hermitian (symmetric if real-valued) and positive-definite. Only `L` is - actually returned. + Hermitian (symmetric if real-valued) and positive-definite. No + checking is performed to verify whether `a` is Hermitian or not. + In addition, only the lower-triangular and diagonal elements of `a` + are used. Only `L` is actually returned. Parameters ---------- From 43386c420affddb2b4e44539ea94971f668187e0 Mon Sep 17 00:00:00 2001 From: Kevin Sheppard Date: Fri, 20 Dec 2019 14:47:12 +0000 Subject: [PATCH 0073/4713] DOC: Correct documentation in choice Correct docstring Correct exception message and standardize Use correct type identifiers --- numpy/random/_generator.pyx | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/numpy/random/_generator.pyx b/numpy/random/_generator.pyx index df4d68927a05..6e4f36a4e036 100644 --- a/numpy/random/_generator.pyx +++ b/numpy/random/_generator.pyx @@ -635,26 +635,26 @@ cdef class Generator: Parameters ---------- - a : 1-D array-like or int + a : {array_like, int} If an ndarray, a random sample is generated from its elements. - If an int, the random sample is generated as if a were np.arange(a) - size : int or tuple of ints, optional + If an int, the random sample is generated from np.arange(a). + size : {int, tuple[int]}, optional Output shape. If the given shape is, e.g., ``(m, n, k)``, then ``m * n * k`` samples are drawn from the 1-d `a`. If `a` has more than one dimension, the `size` shape will be inserted into the `axis` dimension, so the output ``ndim`` will be ``a.ndim - 1 + len(size)``. Default is None, in which case a single value is returned. - replace : boolean, optional + replace : bool, optional Whether the sample is with or without replacement - p : 1-D array-like, optional + p : 1-D array_like, optional The probabilities associated with each entry in a. If not given the sample assumes a uniform distribution over all entries in a. axis : int, optional The axis along which the selection is performed. The default, 0, selects by row. - shuffle : boolean, optional + shuffle : bool, optional Whether the sample is shuffled when sampling without replacement. Default is True, False provides a speedup. @@ -725,13 +725,15 @@ cdef class Generator: # __index__ must return an integer by python rules. pop_size = operator.index(a.item()) except TypeError: - raise ValueError("a must be 1-dimensional or an integer") + raise ValueError("a must an array or an integer") if pop_size <= 0 and np.prod(size) != 0: - raise ValueError("a must be greater than 0 unless no samples are taken") + raise ValueError("a must be a positive integer unless no" + "samples are taken") else: pop_size = a.shape[axis] if pop_size == 0 and np.prod(size) != 0: - raise ValueError("'a' cannot be empty unless no samples are taken") + raise ValueError("a cannot be empty unless no samples are" + "taken") if p is not None: d = len(p) @@ -746,9 +748,9 @@ cdef class Generator: pix = np.PyArray_DATA(p) if p.ndim != 1: - raise ValueError("'p' must be 1-dimensional") + raise ValueError("p must be 1-dimensional") if p.size != pop_size: - raise ValueError("'a' and 'p' must have same size") + raise ValueError("a and p must have same size") p_sum = kahan_sum(pix, d) if np.isnan(p_sum): raise ValueError("probabilities contain NaN") @@ -770,13 +772,14 @@ cdef class Generator: cdf /= cdf[-1] uniform_samples = self.random(shape) idx = cdf.searchsorted(uniform_samples, side='right') - idx = np.array(idx, copy=False, dtype=np.int64) # searchsorted returns a scalar + # searchsorted returns a scalar + idx = np.array(idx, copy=False, dtype=np.int64) else: idx = self.integers(0, pop_size, size=shape, dtype=np.int64) else: if size > pop_size: raise ValueError("Cannot take a larger sample than " - "population when 'replace=False'") + "population when replace is False") elif size < 0: raise ValueError("negative dimensions are not allowed") From 0fd2e0b01031f2225a3faf3ca31355f3cfed37ef Mon Sep 17 00:00:00 2001 From: Kevin Sheppard Date: Mon, 23 Dec 2019 10:01:55 +0000 Subject: [PATCH 0074/4713] DOC: Remove extraneous quote --- numpy/random/_generator.pyx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/numpy/random/_generator.pyx b/numpy/random/_generator.pyx index 6e4f36a4e036..0ba4031382bd 100644 --- a/numpy/random/_generator.pyx +++ b/numpy/random/_generator.pyx @@ -224,7 +224,7 @@ cdef class Generator: capsule = bit_generator.capsule cdef const char *name = "BitGenerator" if not PyCapsule_IsValid(capsule, name): - raise ValueError("Invalid bit generator'. The bit generator must " + raise ValueError("Invalid bit generator. The bit generator must " "be instantiated.") self._bitgen = ( PyCapsule_GetPointer(capsule, name))[0] self.lock = bit_generator.lock From e7002a68f529eb6d275f6c0e2ec9b19443da5ad5 Mon Sep 17 00:00:00 2001 From: Ralf Gommers Date: Mon, 23 Dec 2019 07:12:31 +0100 Subject: [PATCH 0075/4713] DOC: update documentation on how to build NumPy Closes gh-15151 [ci skip] --- INSTALL.rst.txt | 55 +++++++++++++---------------- doc/source/user/building.rst | 68 ++++++++---------------------------- 2 files changed, 39 insertions(+), 84 deletions(-) diff --git a/INSTALL.rst.txt b/INSTALL.rst.txt index d6c42bad7ea7..b33f93683959 100644 --- a/INSTALL.rst.txt +++ b/INSTALL.rst.txt @@ -14,24 +14,17 @@ Prerequisites Building NumPy requires the following installed software: -1) For Python 3, Python__ 3.5.x or newer. +1) Python__ 3.6.x or newer. - On Debian and derivative (Ubuntu): python python-dev + Please note that the Python development headers also need to be installed, + e.g., on Debian/Ubuntu one needs to install both `python3` and + `python3-dev`. On Windows and macOS this is normally not an issue. - On Windows: the official python installer on Python__ is enough - - Make sure that the Python package distutils is installed before - continuing. For example, in Debian GNU/Linux, distutils is included - in the python-dev package. - - Python must also be compiled with the zlib module enabled. - -2) Cython >= 0.29.2 (for development versions of numpy, not for released - versions) +2) Cython >= 0.29.13 3) pytest__ (optional) 1.15 or later - This is required for testing numpy, but not for using it. + This is required for testing NumPy, but not for using it. Python__ http://www.python.org pytest__ http://pytest.readthedocs.io @@ -45,14 +38,14 @@ pytest__ http://pytest.readthedocs.io .. note:: - More extensive information on building NumPy (and Scipy) is maintained at + More extensive information on building NumPy (and SciPy) is maintained at https://scipy.github.io/devdocs/building/ Basic Installation ================== -To install numpy run:: +To install NumPy, run:: python setup.py build -j 4 install --prefix $HOME/.local @@ -88,18 +81,18 @@ installed then ``g77`` will be detected and used first. To explicitly select Windows ------- -On Windows, building from source can be difficult. Currently, the most robust -option is to use the Intel compilers, or alternatively MSVC (the same version -as used to build Python itself) with Intel ifort. Intel itself maintains a -good `application note `_ +On Windows, building from source can be difficult (in particular if you need to +build SciPy as well, because that requires a Fortran compiler). Currently, the +most robust option is to use MSVC (for NumPy only). If you also need SciPy, +you can either use MSVC + Intel Fortran or the Intel compiler suite. +Intel itself maintains a good `application note +`_ on this. -If you want to use a free compiler toolchain, the recommended compiler is MingwPy__. -The older MinGW32 compiler set used to produce older .exe installers for NumPy -itself is still available at https://github.com/numpy/numpy-vendor, but not -recommended for use anymore. - -MingwPy__ https://mingwpy.github.io +If you want to use a free compiler toolchain, our current recommendation is to +use Docker or Windows subsystem for Linux (WSL). See +https://scipy.github.io/devdocs/dev/contributor/contributor_toc.html#development-environment +for more details. Building with optimized BLAS support @@ -114,16 +107,16 @@ Windows ------- The Intel compilers work with Intel MKL, see the application note linked above. -MingwPy__ works with OpenBLAS. + For an overview of the state of BLAS/LAPACK libraries on Windows, see `here `_. -OS X ----- +macOS +----- -OS X ships the Accelerate framework, which NumPy can build against without any -manual configuration. Other BLAS/LAPACK implementations (OpenBLAS, Intel MKL, -ATLAS) will also work. +You will need to install a BLAS/LAPACK library. We recommend using OpenBLAS or +Intel MKL. Apple's Accelerate also still works, however it has bugs and we are +likely to drop support for it in the near future. Ubuntu/Debian ------------- diff --git a/doc/source/user/building.rst b/doc/source/user/building.rst index 1588de964c90..fefbb4e0b52c 100644 --- a/doc/source/user/building.rst +++ b/doc/source/user/building.rst @@ -11,19 +11,11 @@ Prerequisites Building NumPy requires the following software installed: -1) Python 2.7.x, 3.4.x or newer +1) Python 3.6.x or newer - On Debian and derivatives (Ubuntu): python, python-dev (or python3-dev) - - On Windows: the official python installer at - `www.python.org `_ is enough - - Make sure that the Python package distutils is installed before - continuing. For example, in Debian GNU/Linux, installing python-dev - also installs distutils. - - Python must also be compiled with the zlib module enabled. This is - practically always the case with pre-packaged Pythons. + Please note that the Python development headers also need to be installed, + e.g., on Debian/Ubuntu one needs to install both `python3` and + `python3-dev`. On Windows and macOS this is normally not an issue. 2) Compilers @@ -42,19 +34,16 @@ Building NumPy requires the following software installed: NumPy does not require any external linear algebra libraries to be installed. However, if these are available, NumPy's setup script can detect them and use them for building. A number of different LAPACK library setups - can be used, including optimized LAPACK libraries such as ATLAS, MKL or the - Accelerate/vecLib framework on OS X. + can be used, including optimized LAPACK libraries such as OpenBLAS or MKL. 4) Cython - To build development versions of NumPy, you'll need a recent version of - Cython. Released NumPy sources on PyPi include the C files generated from - Cython code, so for released versions having Cython installed isn't needed. + For building NumPy, you'll need a recent version of Cython. Basic Installation ------------------ -To install NumPy run:: +To install NumPy, run:: pip install . @@ -62,10 +51,6 @@ To perform an in-place build that can be run from the source folder run:: python setup.py build_ext --inplace -The NumPy build system uses ``setuptools`` (from numpy 1.11.0, before that it -was plain ``distutils``) and ``numpy.distutils``. -Using ``virtualenv`` should work as expected. - *Note: for build instructions to do development work on NumPy itself, see* :ref:`development-environment`. @@ -83,7 +68,7 @@ For detailed info on testing, see :ref:`testing-builds`. Parallel builds ~~~~~~~~~~~~~~~ -From NumPy 1.10.0 on it's also possible to do a parallel build with:: +It's possible to do a parallel build with:: python setup.py build -j 4 install --prefix $HOME/.local @@ -95,22 +80,11 @@ to perform a parallel in-place build, run:: The number of build jobs can also be specified via the environment variable ``NPY_NUM_BUILD_JOBS``. - -FORTRAN ABI mismatch --------------------- - -The two most popular open source fortran compilers are g77 and gfortran. -Unfortunately, they are not ABI compatible, which means that concretely you -should avoid mixing libraries built with one with another. In particular, if -your blas/lapack/atlas is built with g77, you *must* use g77 when building -numpy and scipy; on the contrary, if your atlas is built with gfortran, you -*must* build numpy/scipy with gfortran. This applies for most other cases -where different FORTRAN compilers might have been used. - Choosing the fortran compiler ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -To build with gfortran:: +Compilers are auto-detected; building with a particular compiler can be done +with ``--fcompiler``. E.g. to select gfortran:: python setup.py build --fcompiler=gnu95 @@ -118,14 +92,14 @@ For more information see:: python setup.py build --help-fcompiler -How to check the ABI of blas/lapack/atlas -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +How to check the ABI of BLAS/LAPACK libraries +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ One relatively simple and reliable way to check for the compiler used to build a library is to use ldd on the library. If libg2c.so is a dependency, this -means that g77 has been used. If libgfortran.so is a dependency, gfortran -has been used. If both are dependencies, this means both have been used, which -is almost always a very bad idea. +means that g77 has been used (note: g77 is no longer supported for building NumPy). +If libgfortran.so is a dependency, gfortran has been used. If both are dependencies, +this means both have been used, which is almost always a very bad idea. Accelerated BLAS/LAPACK libraries --------------------------------- @@ -145,7 +119,6 @@ The default order for the libraries are: 5. Accelerate (MacOS) 6. BLAS (NetLIB) - If you wish to build against OpenBLAS but you also have BLIS available one may predefine the order of searching via the environment variable ``NPY_BLAS_ORDER`` which is a comma-separated list of the above names which @@ -235,14 +208,3 @@ Additional compiler flags can be supplied by setting the ``OPT``, ``FOPT`` (for Fortran), and ``CC`` environment variables. When providing options that should improve the performance of the code ensure that you also set ``-DNDEBUG`` so that debugging code is not executed. - - -Building with ATLAS support ---------------------------- - -Ubuntu -~~~~~~ - -You can install the necessary package for optimized ATLAS with this command:: - - sudo apt-get install libatlas-base-dev From 246b72b1c0c4e9aed592ab69231df4eb09bb5966 Mon Sep 17 00:00:00 2001 From: mattip Date: Mon, 23 Dec 2019 17:06:49 +0200 Subject: [PATCH 0076/4713] DOC: add moved modules to 1.18 release note --- doc/source/release/1.18.0-notes.rst | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/doc/source/release/1.18.0-notes.rst b/doc/source/release/1.18.0-notes.rst index 9ca742eab4a9..7d8102d086d2 100644 --- a/doc/source/release/1.18.0-notes.rst +++ b/doc/source/release/1.18.0-notes.rst @@ -199,6 +199,14 @@ exception will require adaptation, and code that mistakenly called ``numpy.nanmax`` and ``numpy.nanmin``. (`gh-14841 `__) +Moved modules in ``numpy.random`` +--------------------------------- +As part of the API cleanup, the submodules in ``numpy.random`` +``bit_generator``, ``philox``, ``pcg64``, ``sfc64, ``common``, ``generator``, +and ``bounded_integers`` were moved to ``_bit_generator``, ``_philox``, +``_pcg64``, ``_sfc64, ``_common``, ``_generator``, and ``_bounded_integers`` +respectively to indicate that they are not part of the public interface. + C API changes ============= From ed393b8c5bb1891290e7601b0025690b14ecf858 Mon Sep 17 00:00:00 2001 From: mattip Date: Mon, 23 Dec 2019 19:19:01 +0200 Subject: [PATCH 0077/4713] DOC: add PR for note --- doc/source/release/1.18.0-notes.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/source/release/1.18.0-notes.rst b/doc/source/release/1.18.0-notes.rst index 7d8102d086d2..24aa94445ec3 100644 --- a/doc/source/release/1.18.0-notes.rst +++ b/doc/source/release/1.18.0-notes.rst @@ -206,6 +206,7 @@ As part of the API cleanup, the submodules in ``numpy.random`` and ``bounded_integers`` were moved to ``_bit_generator``, ``_philox``, ``_pcg64``, ``_sfc64, ``_common``, ``_generator``, and ``_bounded_integers`` respectively to indicate that they are not part of the public interface. +(`gh-14608 `__) C API changes From 42bd6db6ecfdb0b91e5d08ff587ad9af6d5f42d4 Mon Sep 17 00:00:00 2001 From: Matti Picus Date: Mon, 23 Dec 2019 23:08:24 +0200 Subject: [PATCH 0078/4713] BUG: test, fix flexible dtype conversion on class with __array__ (#15076) Fixes issue gh-12256 where import numpy as np class MyArray: def __array__(self, result=None): return np.array(['0'*70], dtype=object) np.array(MyArray(), dtype=str) # has dtype U64, not U70 The problem was the result of obj.__array__ was not used when filling out a flexible dtype "by-value". I also renamed a test file, over time we should move the tests related to array protocol into it. * BUG: test, fix flexible dtype conversion on class with __array__ * Update numpy/core/_add_newdocs.py Thanks for the correction Co-Authored-By: Eric Wieser Co-authored-by: Eric Wieser --- numpy/core/_add_newdocs.py | 3 +- numpy/core/src/multiarray/ctors.c | 2 +- numpy/core/tests/test_issue14735.py | 29 ------------------- numpy/core/tests/test_protocols.py | 44 +++++++++++++++++++++++++++++ 4 files changed, 46 insertions(+), 32 deletions(-) delete mode 100644 numpy/core/tests/test_issue14735.py create mode 100644 numpy/core/tests/test_protocols.py diff --git a/numpy/core/_add_newdocs.py b/numpy/core/_add_newdocs.py index 2f12739040bb..d552348d0faa 100644 --- a/numpy/core/_add_newdocs.py +++ b/numpy/core/_add_newdocs.py @@ -2507,7 +2507,7 @@ add_newdoc('numpy.core.multiarray', 'ndarray', ('__array__', - """ a.__array__(|dtype) -> reference if type unchanged, copy otherwise. + """ a.__array__([dtype], /) -> reference if type unchanged, copy otherwise. Returns either a new reference to self if dtype is not given or a new array of provided data type if dtype is different from the current dtype of the @@ -6871,4 +6871,3 @@ def add_newdoc_for_scalar_type(obj, fixed_aliases, doc): >>> np.{ftype}(-.25).as_integer_ratio() (-1, 4) """.format(ftype=float_name))) - diff --git a/numpy/core/src/multiarray/ctors.c b/numpy/core/src/multiarray/ctors.c index 7276add75bbe..6921427cebdd 100644 --- a/numpy/core/src/multiarray/ctors.c +++ b/numpy/core/src/multiarray/ctors.c @@ -1909,7 +1909,7 @@ PyArray_FromAny(PyObject *op, PyArray_Descr *newtype, int min_depth, /* If the requested dtype is flexible, adapt it */ if (newtype != NULL) { - newtype = PyArray_AdaptFlexibleDType(op, + newtype = PyArray_AdaptFlexibleDType((arr == NULL) ? op : (PyObject *)arr, (dtype == NULL) ? PyArray_DESCR(arr) : dtype, newtype); if (newtype == NULL) { diff --git a/numpy/core/tests/test_issue14735.py b/numpy/core/tests/test_issue14735.py deleted file mode 100644 index 6105c8e6accc..000000000000 --- a/numpy/core/tests/test_issue14735.py +++ /dev/null @@ -1,29 +0,0 @@ -import pytest -import warnings -import numpy as np - - -class Wrapper: - def __init__(self, array): - self.array = array - - def __len__(self): - return len(self.array) - - def __getitem__(self, item): - return type(self)(self.array[item]) - - def __getattr__(self, name): - if name.startswith("__array_"): - warnings.warn("object got converted", UserWarning, stacklevel=1) - - return getattr(self.array, name) - - def __repr__(self): - return "".format(self=self) - -@pytest.mark.filterwarnings("error") -def test_getattr_warning(): - array = Wrapper(np.arange(10)) - with pytest.raises(UserWarning, match="object got converted"): - np.asarray(array) diff --git a/numpy/core/tests/test_protocols.py b/numpy/core/tests/test_protocols.py new file mode 100644 index 000000000000..55a2bcf72fad --- /dev/null +++ b/numpy/core/tests/test_protocols.py @@ -0,0 +1,44 @@ +import pytest +import warnings +import numpy as np + + +@pytest.mark.filterwarnings("error") +def test_getattr_warning(): + # issue gh-14735: make sure we clear only getattr errors, and let warnings + # through + class Wrapper: + def __init__(self, array): + self.array = array + + def __len__(self): + return len(self.array) + + def __getitem__(self, item): + return type(self)(self.array[item]) + + def __getattr__(self, name): + if name.startswith("__array_"): + warnings.warn("object got converted", UserWarning, stacklevel=1) + + return getattr(self.array, name) + + def __repr__(self): + return "".format(self=self) + + array = Wrapper(np.arange(10)) + with pytest.raises(UserWarning, match="object got converted"): + np.asarray(array) + + +def test_array_called(): + class Wrapper: + val = '0' * 100 + def __array__(self, result=None): + return np.array([self.val], dtype=object) + + + wrapped = Wrapper() + arr = np.array(wrapped, dtype=str) + assert arr.dtype == 'U100' + assert arr[0] == Wrapper.val From a7928319d264871a5d95b39ab334884501992676 Mon Sep 17 00:00:00 2001 From: Charles Harris Date: Mon, 23 Dec 2019 14:56:47 -0700 Subject: [PATCH 0079/4713] MAINT: Update required cython version to 0.29.14. This is needed for the latest fixes for Python 3.8. --- INSTALL.rst.txt | 2 +- pyproject.toml | 2 +- tools/cythonize.py | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/INSTALL.rst.txt b/INSTALL.rst.txt index b33f93683959..30f58fa6d31c 100644 --- a/INSTALL.rst.txt +++ b/INSTALL.rst.txt @@ -20,7 +20,7 @@ Building NumPy requires the following installed software: e.g., on Debian/Ubuntu one needs to install both `python3` and `python3-dev`. On Windows and macOS this is normally not an issue. -2) Cython >= 0.29.13 +2) Cython >= 0.29.14 3) pytest__ (optional) 1.15 or later diff --git a/pyproject.toml b/pyproject.toml index 918cbb2780b6..d81b731d3648 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,7 +3,7 @@ requires = [ "setuptools", "wheel", - "Cython>=0.29.13", # Note: keep in sync with tools/cythonize.py + "Cython>=0.29.14", # Note: keep in sync with tools/cythonize.py ] diff --git a/tools/cythonize.py b/tools/cythonize.py index 5bea2d4ecf2b..e5352a9542b1 100755 --- a/tools/cythonize.py +++ b/tools/cythonize.py @@ -68,11 +68,11 @@ def process_pyx(fromfile, tofile): # check the version, and invoke through python from distutils.version import LooseVersion - # Cython 0.29.13 is required for Python 3.8 and there are + # Cython 0.29.14 is required for Python 3.8 and there are # 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.13') + required_version = LooseVersion('0.29.14') if LooseVersion(cython_version) < required_version: raise RuntimeError('Building {} requires Cython >= {}'.format( From a13100cd5097a7ea467bbd9cd72ad23bd46a25d2 Mon Sep 17 00:00:00 2001 From: Keewis Date: Tue, 24 Dec 2019 14:11:38 +0100 Subject: [PATCH 0080/4713] BUG: rename the argument name of searchsorted --- numpy/core/src/multiarray/methods.c | 2 +- numpy/core/tests/test_multiarray.py | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/numpy/core/src/multiarray/methods.c b/numpy/core/src/multiarray/methods.c index e5845f2f64d9..ae26bbd4ab31 100644 --- a/numpy/core/src/multiarray/methods.c +++ b/numpy/core/src/multiarray/methods.c @@ -1469,7 +1469,7 @@ array_argpartition(PyArrayObject *self, PyObject *args, PyObject *kwds) static PyObject * array_searchsorted(PyArrayObject *self, PyObject *args, PyObject *kwds) { - static char *kwlist[] = {"keys", "side", "sorter", NULL}; + static char *kwlist[] = {"v", "side", "sorter", NULL}; PyObject *keys; PyObject *sorter; NPY_SEARCHSIDE side = NPY_SEARCHLEFT; diff --git a/numpy/core/tests/test_multiarray.py b/numpy/core/tests/test_multiarray.py index d801dbf917ce..fb9d8066137d 100644 --- a/numpy/core/tests/test_multiarray.py +++ b/numpy/core/tests/test_multiarray.py @@ -2144,6 +2144,8 @@ def test_searchsorted(self): msg = "Test real searchsorted with nans, side='r'" b = a.searchsorted(a, side='r') assert_equal(b, np.arange(1, 4), msg) + # check keyword arguments + a.searchsorted(v=1) # check double complex a = np.zeros(9, dtype=np.complex128) a.real += [0, 0, 1, 1, 0, 1, np.nan, np.nan, np.nan] From a1bfe6e3c9cfd81a0ca235cd806ab7098dd93a5c Mon Sep 17 00:00:00 2001 From: Maxwell Aladago Date: Thu, 22 Aug 2019 10:43:21 -0400 Subject: [PATCH 0081/4713] TST: Add assert_array_equal test for big integer arrays --- numpy/testing/tests/test_utils.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/numpy/testing/tests/test_utils.py b/numpy/testing/tests/test_utils.py index d14d4090c7df..ad72b919983d 100644 --- a/numpy/testing/tests/test_utils.py +++ b/numpy/testing/tests/test_utils.py @@ -90,6 +90,21 @@ def foo(t): for t in ['S1', 'U1']: foo(t) + def test_0_ndim_array(self): + x = np.array(473963742225900817127911193656584771) + y = np.array(18535119325151578301457182298393896) + assert_raises(AssertionError, self._assert_func, x, y) + + y = x + self._assert_func(x, y) + + x = np.array(43) + y = np.array(10) + assert_raises(AssertionError, self._assert_func, x, y) + + y = x + self._assert_func(x, y) + def test_generic_rank3(self): """Test rank 3 array for all dtypes.""" def foo(t): From 48089a72d6f4c3805ce0a53618cc9652287c5018 Mon Sep 17 00:00:00 2001 From: Ralf Gommers Date: Thu, 26 Dec 2019 07:21:59 +0100 Subject: [PATCH 0082/4713] TST: improve assert message of assert_array_max_ulp It was not showing the max difference before, which makes it hard to judge whether something is seriously wrong, or the test precision simply needs to be bumped by a little. --- numpy/testing/_private/utils.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/numpy/testing/_private/utils.py b/numpy/testing/_private/utils.py index 23267a9e1f72..870671d05ca1 100644 --- a/numpy/testing/_private/utils.py +++ b/numpy/testing/_private/utils.py @@ -1636,8 +1636,9 @@ def assert_array_max_ulp(a, b, maxulp=1, dtype=None): import numpy as np ret = nulp_diff(a, b, dtype) if not np.all(ret <= maxulp): - raise AssertionError("Arrays are not almost equal up to %g ULP" % - maxulp) + raise AssertionError("Arrays are not almost equal up to %g " + "ULP (max difference is %g ULP)" % + (maxulp, np.max(ret))) return ret From c18b3f59b5f5752ab038224fd3bdf2dadba55ecf Mon Sep 17 00:00:00 2001 From: Matti Picus Date: Thu, 26 Dec 2019 17:23:49 +0200 Subject: [PATCH 0083/4713] BUG: use tmp dir and check version for cython test (#15170) * BUG: use tmp dir and check version for cython test * TST, MAINT: skip on win32, fix formatting * TST: fixes from review * TST: fixes from review * TST: fixes from review --- numpy/random/_examples/cython/setup.py | 6 +++- numpy/random/tests/test_extending.py | 39 +++++++++++++++----------- 2 files changed, 28 insertions(+), 17 deletions(-) diff --git a/numpy/random/_examples/cython/setup.py b/numpy/random/_examples/cython/setup.py index 19f045fc00b5..7ed0a3a18a99 100644 --- a/numpy/random/_examples/cython/setup.py +++ b/numpy/random/_examples/cython/setup.py @@ -12,6 +12,7 @@ from os.path import join, abspath, dirname path = abspath(dirname(__file__)) +defs = [('NPY_NO_DEPRECATED_API', 0)] extending = Extension("extending", sources=[join(path, 'extending.pyx')], @@ -19,10 +20,13 @@ np.get_include(), join(path, '..', '..') ], + define_macros=defs, ) distributions = Extension("extending_distributions", sources=[join(path, 'extending_distributions.pyx')], - include_dirs=[np.get_include()]) + include_dirs=[np.get_include()], + define_macros=defs, + ) extensions = [extending, distributions] diff --git a/numpy/random/tests/test_extending.py b/numpy/random/tests/test_extending.py index 807de1a25164..0cad76ed1278 100644 --- a/numpy/random/tests/test_extending.py +++ b/numpy/random/tests/test_extending.py @@ -1,6 +1,8 @@ import os, sys import pytest import warnings +import shutil +import subprocess try: import cffi @@ -22,30 +24,35 @@ try: import cython + from Cython.Compiler.Version import version as cython_version except ImportError: cython = None +else: + from distutils.version import LooseVersion + # Cython 0.29.14 is required for Python 3.8 and there are + # other fixes in the 0.29 series that are needed even for earlier + # Python versions. + # Note: keep in sync with the one in pyproject.toml + required_version = LooseVersion('0.29.14') + if LooseVersion(cython_version) < required_version: + # too old or wrong cython, skip the test + cython = None @pytest.mark.skipif(cython is None, reason="requires cython") -def test_cython(): - curdir = os.getcwd() - argv = sys.argv - examples = (os.path.dirname(__file__), '..', '_examples') - try: - os.chdir(os.path.join(*examples)) - sys.argv = argv[:1] + ['build'] - with warnings.catch_warnings(record=True) as w: - # setuptools issue gh-1885 - warnings.filterwarnings('always', '', DeprecationWarning) - from numpy.random._examples.cython import setup - finally: - sys.argv = argv - os.chdir(curdir) +@pytest.mark.slow +@pytest.mark.skipif(sys.platform == 'win32', reason="cmd too long on CI") +def test_cython(tmp_path): + examples = os.path.join(os.path.dirname(__file__), '..', '_examples') + base = os.path.dirname(examples) + shutil.copytree(examples, tmp_path / '_examples') + subprocess.check_call([sys.executable, 'setup.py', 'build'], + cwd=str(tmp_path / '_examples' / 'cython')) @pytest.mark.skipif(numba is None or cffi is None, reason="requires numba and cffi") def test_numba(): - from numpy.random._examples.numba import extending + from numpy.random._examples.numba import extending @pytest.mark.skipif(cffi is None, reason="requires cffi") def test_cffi(): - from numpy.random._examples.cffi import extending + from numpy.random._examples.cffi import extending From af6e61668ac3598daca111e7ed81bcca5e910735 Mon Sep 17 00:00:00 2001 From: mattip Date: Fri, 27 Dec 2019 09:28:25 +0200 Subject: [PATCH 0084/4713] MAINT: unskip test on win32 --- numpy/random/_examples/cython/setup.py | 4 ++-- numpy/random/tests/test_extending.py | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/numpy/random/_examples/cython/setup.py b/numpy/random/_examples/cython/setup.py index 7ed0a3a18a99..20cedc4e38f0 100644 --- a/numpy/random/_examples/cython/setup.py +++ b/numpy/random/_examples/cython/setup.py @@ -9,9 +9,9 @@ from distutils.core import setup from Cython.Build import cythonize from setuptools.extension import Extension -from os.path import join, abspath, dirname +from os.path import join, dirname -path = abspath(dirname(__file__)) +path = dirname(__file__) defs = [('NPY_NO_DEPRECATED_API', 0)] extending = Extension("extending", diff --git a/numpy/random/tests/test_extending.py b/numpy/random/tests/test_extending.py index 0cad76ed1278..439980fd4319 100644 --- a/numpy/random/tests/test_extending.py +++ b/numpy/random/tests/test_extending.py @@ -40,7 +40,6 @@ @pytest.mark.skipif(cython is None, reason="requires cython") @pytest.mark.slow -@pytest.mark.skipif(sys.platform == 'win32', reason="cmd too long on CI") def test_cython(tmp_path): examples = os.path.join(os.path.dirname(__file__), '..', '_examples') base = os.path.dirname(examples) From 867eb78d25a0640c43b67bc7d3d0fe068ba85680 Mon Sep 17 00:00:00 2001 From: mattip Date: Fri, 27 Dec 2019 13:29:42 +0200 Subject: [PATCH 0085/4713] MAINT: remove dead code from review --- numpy/random/tests/test_extending.py | 1 - 1 file changed, 1 deletion(-) diff --git a/numpy/random/tests/test_extending.py b/numpy/random/tests/test_extending.py index 439980fd4319..23a874fb1617 100644 --- a/numpy/random/tests/test_extending.py +++ b/numpy/random/tests/test_extending.py @@ -42,7 +42,6 @@ @pytest.mark.slow def test_cython(tmp_path): examples = os.path.join(os.path.dirname(__file__), '..', '_examples') - base = os.path.dirname(examples) shutil.copytree(examples, tmp_path / '_examples') subprocess.check_call([sys.executable, 'setup.py', 'build'], cwd=str(tmp_path / '_examples' / 'cython')) From 49b0d2e2f71d78168eb38ea6deb52374e2227540 Mon Sep 17 00:00:00 2001 From: Ross Barnowski Date: Sun, 29 Dec 2019 15:16:46 -0800 Subject: [PATCH 0086/4713] DOC: Initialize submodules to build docs. Added instructions to the developer guide on initializing the submodules containing numpydoc and the scipy sphinx theme before building the documentation. --- doc/source/dev/index.rst | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/doc/source/dev/index.rst b/doc/source/dev/index.rst index 306c150697fd..da225d8da9a0 100644 --- a/doc/source/dev/index.rst +++ b/doc/source/dev/index.rst @@ -231,6 +231,17 @@ Requirements `Sphinx `__ is needed to build the documentation. Matplotlib, SciPy, and IPython are also required. +The numpy documentation also depends on the +`numpydoc `__ sphinx extension +as well as an external sphinx theme. +These extensions are included as git submodules and must be initialized +before building the docs. +From the ``doc/`` directory: + +.. code:: sh + + git submodule update --init + Fixing Warnings ~~~~~~~~~~~~~~~ From b9e2cdd448e10cb6aa721cf13e0a16084ab634c9 Mon Sep 17 00:00:00 2001 From: Ross Barnowski Date: Sun, 29 Dec 2019 15:50:36 -0800 Subject: [PATCH 0087/4713] DOC: Added note about LaTeX requirement Building the html docs from source requires a working LaTeX build environment to get the equations rendered properly. --- doc/source/dev/index.rst | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/doc/source/dev/index.rst b/doc/source/dev/index.rst index da225d8da9a0..1aacc2c49447 100644 --- a/doc/source/dev/index.rst +++ b/doc/source/dev/index.rst @@ -242,6 +242,11 @@ From the ``doc/`` directory: git submodule update --init +The documentation includes mathematical formulae with LaTeX formatting. +A working LaTeX document production system +(e.g. `texlive `__) is required for the +proper rendering of the LaTeX math in the documentation. + Fixing Warnings ~~~~~~~~~~~~~~~ From 63ef78b1cb80ae52dae115afa2463510336e6759 Mon Sep 17 00:00:00 2001 From: Matti Picus Date: Mon, 30 Dec 2019 19:14:39 +0200 Subject: [PATCH 0088/4713] BUG: remove -std=c99 for c++ compilation (#15194) This flag is only legal for C compilers --- numpy/distutils/ccompiler.py | 2 +- numpy/distutils/tests/test_ccompiler.py | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 numpy/distutils/tests/test_ccompiler.py diff --git a/numpy/distutils/ccompiler.py b/numpy/distutils/ccompiler.py index 684c7535b76b..c3a557f50e89 100644 --- a/numpy/distutils/ccompiler.py +++ b/numpy/distutils/ccompiler.py @@ -532,7 +532,7 @@ def CCompiler_customize(self, dist, need_cxx=0): 'g++' in self.compiler[0] or 'clang' in self.compiler[0]): self._auto_depends = True - if 'gcc' in self.compiler[0]: + if 'gcc' in self.compiler[0] and not need_cxx: # add std=c99 flag for gcc # TODO: does this need to be more specific? self.compiler.append('-std=c99') diff --git a/numpy/distutils/tests/test_ccompiler.py b/numpy/distutils/tests/test_ccompiler.py new file mode 100644 index 000000000000..8b4a56b79085 --- /dev/null +++ b/numpy/distutils/tests/test_ccompiler.py @@ -0,0 +1,24 @@ +from __future__ import division, absolute_import, print_function + +from distutils.ccompiler import new_compiler + +from numpy.distutils.numpy_distribution import NumpyDistribution + +def test_ccompiler(): + ''' + scikit-image/scikit-image issue 4369 + We unconditionally add ``-std-c99`` to the gcc compiler in order + to support c99 with very old gcc compilers. However the same call + is used to get the flags for the c++ compiler, just with a kwarg. + Make sure in this case, where it would not be legal, the option is **not** added + ''' + dist = NumpyDistribution() + compiler = new_compiler() + compiler.customize(dist) + if hasattr(compiler, 'compiler') and 'gcc' in compiler.compiler[0]: + assert 'c99' in ' '.join(compiler.compiler) + + compiler = new_compiler() + compiler.customize(dist, need_cxx=True) + if hasattr(compiler, 'compiler') and 'gcc' in compiler.compiler[0]: + assert 'c99' not in ' '.join(compiler.compiler) From 8a748a939feb98375eb11301262a0e3198b6c338 Mon Sep 17 00:00:00 2001 From: mattip Date: Mon, 30 Dec 2019 20:05:00 +0200 Subject: [PATCH 0089/4713] MAINT: refactor function out of test module --- numpy/core/tests/test_multiarray.py | 33 +++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 7 deletions(-) diff --git a/numpy/core/tests/test_multiarray.py b/numpy/core/tests/test_multiarray.py index d801dbf917ce..0ef1819f8937 100644 --- a/numpy/core/tests/test_multiarray.py +++ b/numpy/core/tests/test_multiarray.py @@ -20,7 +20,6 @@ import weakref import pytest from contextlib import contextmanager -from test.support import no_tracing from numpy.compat import pickle @@ -97,6 +96,26 @@ def _aligned_zeros(shape, dtype=float, order="C", align=None): data.fill(0) return data +def _no_tracing(func): + """ + Decorator to temporarily turn off tracing for the duration of a test. + Needed in tests that check refcounting, otherwise the tracing itself + influences the refcounts + """ + if not hasattr(sys, 'gettrace'): + return func + else: + @functools.wraps(func) + def wrapper(*args, **kwargs): + original_trace = sys.gettrace() + try: + sys.settrace(None) + return func(*args, **kwargs) + finally: + sys.settrace(original_trace) + return wrapper + + class TestFlags(object): def setup(self): @@ -5098,7 +5117,7 @@ def test_refcount(self): class TestResize(object): - @no_tracing + @_no_tracing def test_basic(self): x = np.array([[1, 0, 0], [0, 1, 0], [0, 0, 1]]) if IS_PYPY: @@ -5115,7 +5134,7 @@ def test_check_reference(self): assert_raises(ValueError, x.resize, (5, 1)) del y # avoid pyflakes unused variable warning. - @no_tracing + @_no_tracing def test_int_shape(self): x = np.eye(3) if IS_PYPY: @@ -5149,7 +5168,7 @@ def test_invalid_arguments(self): assert_raises(TypeError, np.eye(3).resize, order=1) assert_raises(TypeError, np.eye(3).resize, refcheck='hi') - @no_tracing + @_no_tracing def test_freeform_shape(self): x = np.eye(3) if IS_PYPY: @@ -5158,7 +5177,7 @@ def test_freeform_shape(self): x.resize(3, 2, 1) assert_(x.shape == (3, 2, 1)) - @no_tracing + @_no_tracing def test_zeros_appended(self): x = np.eye(3) if IS_PYPY: @@ -5168,7 +5187,7 @@ def test_zeros_appended(self): assert_array_equal(x[0], np.eye(3)) assert_array_equal(x[1], np.zeros((3, 3))) - @no_tracing + @_no_tracing def test_obj_obj(self): # check memory is initialized on resize, gh-4857 a = np.ones(10, dtype=[('k', object, 2)]) @@ -7789,7 +7808,7 @@ def test_reshape(self): d = np.ones(100) assert_(sys.getsizeof(d) < sys.getsizeof(d.reshape(100, 1, 1).copy())) - @no_tracing + @_no_tracing def test_resize(self): d = np.ones(100) old = sys.getsizeof(d) From 280802a9f17ef2f5cdb391425ebe155cb6c03af2 Mon Sep 17 00:00:00 2001 From: Ross Barnowski Date: Mon, 30 Dec 2019 11:45:41 -0800 Subject: [PATCH 0090/4713] DOC: Improvements to Quickstart Tutorial. * Modified reference to array creation with a list to the more general term 'sequence'. Also removed the 'numeric' distinction. * Updated reference to arange to reflect that as of Python 3, the python built-in range does not return a list. * Fixed 'see also' references to invert and r_ which were not linked properly. * Replaced referenced to ma.row_stack with the more general row_stack. Added additional detail about the aliasing of vstack. * Updated array stacking example to include proper rST python syntax. --- doc/source/user/quickstart.rst | 44 +++++++++++++++++++++------------- 1 file changed, 27 insertions(+), 17 deletions(-) diff --git a/doc/source/user/quickstart.rst b/doc/source/user/quickstart.rst index 6211d0c69b80..34e327d759c2 100644 --- a/doc/source/user/quickstart.rst +++ b/doc/source/user/quickstart.rst @@ -117,9 +117,8 @@ from the type of the elements in the sequences. >>> b.dtype dtype('float64') -A frequent error consists in calling ``array`` with multiple numeric -arguments, rather than providing a single list of numbers as an -argument. +A frequent error consists in calling ``array`` with multiple arguments, +rather than providing a single sequence as an argument. :: @@ -174,8 +173,9 @@ state of the memory. By default, the dtype of the created array is array([[ 3.73603959e-262, 6.02658058e-154, 6.55490914e-260], [ 5.30498948e-313, 3.14673309e-307, 1.00000000e+000]]) -To create sequences of numbers, NumPy provides a function analogous to -``range`` that returns arrays instead of lists. +To create sequences of numbers, NumPy provides the ``arange`` function +which is analogous to the Python built-in ``range``, but returns an +array. :: @@ -300,9 +300,9 @@ elementwise in NumPy arrays. The matrix product can be performed using the ``@`` operator (in python >=3.5) or the ``dot`` function or method:: >>> A = np.array( [[1,1], - ... [0,1]] ) + ... [0,1]] ) >>> B = np.array( [[2,0], - ... [3,4]] ) + ... [3,4]] ) >>> A * B # elementwise product array([[2, 0], [0, 4]]) @@ -437,7 +437,7 @@ operate elementwise on an array, producing an array as output. `dot`, `floor`, `inner`, - `inv`, + `invert`, `lexsort`, `max`, `maximum`, @@ -732,8 +732,14 @@ stacks 1D arrays as columns into a 2D array. It is equivalent to array([[ 4., 3.], [ 2., 8.]]) -On the other hand, the function `ma.row_stack` is equivalent to `vstack` -for any input arrays. +On the other hand, the function `row_stack` is equivalent to `vstack` +for any input arrays. In fact, `row_stack` is an alias for `vstack`:: + + >>> np.column_stack is np.hstack + False + >>> np.row_stack is np.vstack + True + In general, for arrays with more than two dimensions, `hstack` stacks along their second axes, `vstack` stacks along their @@ -917,7 +923,7 @@ Array Creation `ogrid`, `ones`, `ones_like`, - `r`, + `r_`, `zeros`, `zeros_like` Conversions @@ -1431,11 +1437,15 @@ functions ``column_stack``, ``dstack``, ``hstack`` and ``vstack``, depending on the dimension in which the stacking is to be done. For example:: - x = np.arange(0,10,2) # x=([0,2,4,6,8]) - y = np.arange(5) # y=([0,1,2,3,4]) - m = np.vstack([x,y]) # m=([[0,2,4,6,8], - # [0,1,2,3,4]]) - xy = np.hstack([x,y]) # xy =([0,2,4,6,8,0,1,2,3,4]) + >>> x = np.arange(0,10,2) + >>> y = np.arange(5) + >>> m = np.vstack([x,y]) + >>> m + array([[0, 2, 4, 6, 8], + [0, 1, 2, 3, 4]]) + >>> xy = np.hstack([x,y]) + >>> xy + array([0, 2, 4, 6, 8, 0, 1, 2, 3, 4]) The logic behind those functions in more than two dimensions can be strange. @@ -1448,7 +1458,7 @@ Histograms ---------- The NumPy ``histogram`` function applied to an array returns a pair of -vectors: the histogram of the array and the vector of bins. Beware: +vectors: the histogram of the array and a vector of the bin edges. Beware: ``matplotlib`` also has a function to build histograms (called ``hist``, as in Matlab) that differs from the one in NumPy. The main difference is that ``pylab.hist`` plots the histogram automatically, while From dc0adc9aeb59ce6de9c6ce7938e8c91133a05420 Mon Sep 17 00:00:00 2001 From: Pauli Virtanen Date: Tue, 31 Dec 2019 01:21:48 +0200 Subject: [PATCH 0091/4713] BUG: distutils: fix msvc+gfortran openblas handling corner case Ensure the openblas MSVC+gfortran temporary library names are unique for the different openblas_* system_info classes. If multiple openblas libraries (e.g. both a 32-bit and a 64-bit one) are used in the same project, when compiling in the msvc+gfortran mode, this previously resulted to only the last one being used. --- numpy/distutils/system_info.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/numpy/distutils/system_info.py b/numpy/distutils/system_info.py index 4786b3a0cc93..fc7018af3490 100644 --- a/numpy/distutils/system_info.py +++ b/numpy/distutils/system_info.py @@ -2102,16 +2102,17 @@ def check_msvc_gfortran_libs(self, library_dirs, libraries): return None # Generate numpy.distutils virtual static library file - tmpdir = os.path.join(os.getcwd(), 'build', 'openblas') + basename = self.__class__.__name__ + tmpdir = os.path.join(os.getcwd(), 'build', basename) if not os.path.isdir(tmpdir): os.makedirs(tmpdir) info = {'library_dirs': [tmpdir], - 'libraries': ['openblas'], + 'libraries': [basename], 'language': 'f77'} - fake_lib_file = os.path.join(tmpdir, 'openblas.fobjects') - fake_clib_file = os.path.join(tmpdir, 'openblas.cobjects') + fake_lib_file = os.path.join(tmpdir, basename + '.fobjects') + fake_clib_file = os.path.join(tmpdir, basename + '.cobjects') with open(fake_lib_file, 'w') as f: f.write("\n".join(library_paths)) with open(fake_clib_file, 'w') as f: From 618da442031edf29606ab52a4626f6e43411cafd Mon Sep 17 00:00:00 2001 From: Warren Weckesser Date: Wed, 1 Jan 2020 07:13:25 -0500 Subject: [PATCH 0092/4713] MAINT: lib: Clean up in _iotools.py * Remove the unused function _to_filehandle(). * Remove conditional imports that handled Python 2. * Remove unused imports. * Fix a few line lengths (PEP 8). --- numpy/lib/_iotools.py | 51 +++++-------------------------------------- 1 file changed, 6 insertions(+), 45 deletions(-) diff --git a/numpy/lib/_iotools.py b/numpy/lib/_iotools.py index c392929fd879..8bc336fdb38b 100644 --- a/numpy/lib/_iotools.py +++ b/numpy/lib/_iotools.py @@ -5,17 +5,10 @@ __docformat__ = "restructuredtext en" -import sys import numpy as np import numpy.core.numeric as nx from numpy.compat import asbytes, asunicode, bytes, basestring -if sys.version_info[0] >= 3: - from builtins import bool, int, float, complex, object, str - unicode = str -else: - from __builtin__ import bool, int, float, complex, object, unicode, str - def _decode_line(line, encoding=None): """Decode bytes from binary input streams. @@ -65,40 +58,6 @@ def _is_bytes_like(obj): return True -def _to_filehandle(fname, flag='r', return_opened=False): - """ - Returns the filehandle corresponding to a string or a file. - If the string ends in '.gz', the file is automatically unzipped. - - Parameters - ---------- - fname : string, filehandle - Name of the file whose filehandle must be returned. - flag : string, optional - Flag indicating the status of the file ('r' for read, 'w' for write). - return_opened : boolean, optional - Whether to return the opening status of the file. - """ - if _is_string_like(fname): - if fname.endswith('.gz'): - import gzip - fhd = gzip.open(fname, flag) - elif fname.endswith('.bz2'): - import bz2 - fhd = bz2.BZ2File(fname) - else: - fhd = file(fname, flag) - opened = True - elif hasattr(fname, 'seek'): - fhd = fname - opened = False - else: - raise ValueError('fname must be a string or file handle') - if return_opened: - return fhd, opened - return fhd - - def has_nested_fields(ndtype): """ Returns whether one or several fields of a dtype are nested. @@ -210,7 +169,8 @@ def autostrip(self, method): return lambda input: [_.strip() for _ in method(input)] # - def __init__(self, delimiter=None, comments='#', autostrip=True, encoding=None): + def __init__(self, delimiter=None, comments='#', autostrip=True, + encoding=None): delimiter = _decode_line(delimiter) comments = _decode_line(comments) @@ -949,9 +909,10 @@ def easy_dtype(ndtype, names=None, defaultfmt="f%i", **validationargs): elif ndtype.names is not None: validate = NameValidator(**validationargs) # Default initial names : should we change the format ? - if ((ndtype.names == tuple("f%i" % i for i in range(len(ndtype.names)))) and - (defaultfmt != "f%i")): - ndtype.names = validate([''] * len(ndtype.names), defaultfmt=defaultfmt) + numbered_names = tuple("f%i" % i for i in range(len(ndtype.names))) + if ((ndtype.names == numbered_names) and (defaultfmt != "f%i")): + ndtype.names = validate([''] * len(ndtype.names), + defaultfmt=defaultfmt) # Explicit initial names : just validate else: ndtype.names = validate(ndtype.names, defaultfmt=defaultfmt) From 71663b5030567f32b82b6471e916c0571344b0fa Mon Sep 17 00:00:00 2001 From: Warren Weckesser Date: Wed, 1 Jan 2020 07:39:03 -0500 Subject: [PATCH 0093/4713] MAINT: lib: Clean up in function_base.py. * Remove conditional imports that handled Python 2. * Remove unused imports. * Partial PEP 8 clean up. --- numpy/lib/function_base.py | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/numpy/lib/function_base.py b/numpy/lib/function_base.py index 499120630b96..c2680b016fe9 100644 --- a/numpy/lib/function_base.py +++ b/numpy/lib/function_base.py @@ -13,10 +13,10 @@ import numpy as np import numpy.core.numeric as _nx -from numpy.core import atleast_1d, transpose +from numpy.core import transpose from numpy.core.numeric import ( ones, zeros, arange, concatenate, array, asarray, asanyarray, empty, - empty_like, ndarray, around, floor, ceil, take, dot, where, intp, + ndarray, around, floor, ceil, take, dot, where, intp, integer, isscalar, absolute ) from numpy.core.umath import ( @@ -38,21 +38,16 @@ from numpy.core.umath import _add_newdoc_ufunc as add_newdoc_ufunc from numpy.compat import long -if sys.version_info[0] < 3: - # Force range to be a generator, for np.delete's usage. - range = xrange - import __builtin__ as builtins -else: - import builtins +import builtins + +# needed in this module for compatibility +from numpy.lib.histograms import histogram, histogramdd array_function_dispatch = functools.partial( overrides.array_function_dispatch, module='numpy') -# needed in this module for compatibility -from numpy.lib.histograms import histogram, histogramdd - __all__ = [ 'select', 'piecewise', 'trim_zeros', 'copy', 'iterable', 'percentile', 'diff', 'gradient', 'angle', 'unwrap', 'sort_complex', 'disp', 'flip', @@ -70,7 +65,7 @@ def _rot90_dispatcher(m, k=None, axes=None): @array_function_dispatch(_rot90_dispatcher) -def rot90(m, k=1, axes=(0,1)): +def rot90(m, k=1, axes=(0, 1)): """ Rotate an array by 90 degrees in the plane specified by axes. @@ -150,7 +145,7 @@ def rot90(m, k=1, axes=(0,1)): axes_list[axes[0]]) if k == 1: - return transpose(flip(m,axes[1]), axes_list) + return transpose(flip(m, axes[1]), axes_list) else: # k == 3 return flip(transpose(m, axes_list), axes[1]) @@ -1612,6 +1607,7 @@ def trim_zeros(filt, trim='fb'): last = last - 1 return filt[first:last] + def _extract_dispatcher(condition, arr): return (condition, arr) @@ -2947,6 +2943,7 @@ def hamming(M): n = arange(0, M) return 0.54 - 0.46*cos(2.0*pi*n/(M-1)) + ## Code from cephes for i0 _i0A = [ @@ -3489,6 +3486,7 @@ def median(a, axis=None, out=None, overwrite_input=False, keepdims=False): else: return r + def _median(a, axis=None, out=None, overwrite_input=False): # can't be reasonably be implemented in terms of percentile as we have to # call mean to not break astropy @@ -3707,7 +3705,7 @@ def quantile(a, q, axis=None, out=None, overwrite_input=False, interpolation='linear', keepdims=False): """ Compute the q-th quantile of the data along the specified axis. - + .. versionadded:: 1.15.0 Parameters @@ -3878,7 +3876,7 @@ def _quantile_ureduce_func(a, q, axis=None, out=None, overwrite_input=False, "interpolation can only be 'linear', 'lower' 'higher', " "'midpoint', or 'nearest'") - n = np.array(False, dtype=bool) # check for nan's flag + n = np.array(False, dtype=bool) # check for nan's flag if indices.dtype == intp: # take the points along axis # Check if the array contains any nan's if np.issubdtype(a.dtype, np.inexact): @@ -3898,7 +3896,6 @@ def _quantile_ureduce_func(a, q, axis=None, out=None, overwrite_input=False, indices = indices[0] r = take(ap, indices, axis=axis, out=out) - else: # weight the points above and below the indices indices_below = floor(indices).astype(intp) indices_above = indices_below + 1 From baa3786ef02cb8d56ed1c16a105b857e87adf29a Mon Sep 17 00:00:00 2001 From: Warren Weckesser Date: Wed, 1 Jan 2020 07:42:57 -0500 Subject: [PATCH 0094/4713] MAINT: lib: Clean up in twodim_base.py. * Remove unused imports. --- numpy/lib/twodim_base.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/numpy/lib/twodim_base.py b/numpy/lib/twodim_base.py index f453921885c2..2e6d30a1d18e 100644 --- a/numpy/lib/twodim_base.py +++ b/numpy/lib/twodim_base.py @@ -6,13 +6,13 @@ import functools from numpy.core.numeric import ( - absolute, asanyarray, arange, zeros, greater_equal, multiply, ones, + asanyarray, arange, zeros, greater_equal, multiply, ones, asarray, where, int8, int16, int32, int64, empty, promote_types, diagonal, nonzero ) from numpy.core.overrides import set_module from numpy.core import overrides -from numpy.core import iinfo, transpose +from numpy.core import iinfo __all__ = [ From d690452646711f9091c73de471463e795d12acfc Mon Sep 17 00:00:00 2001 From: Warren Weckesser Date: Wed, 1 Jan 2020 07:50:29 -0500 Subject: [PATCH 0095/4713] MAINT: lib: Clean up in tests. * Remove a few unused imports in several files. --- numpy/lib/tests/test_function_base.py | 1 - numpy/lib/tests/test_recfunctions.py | 1 - numpy/lib/tests/test_shape_base.py | 1 - 3 files changed, 3 deletions(-) diff --git a/numpy/lib/tests/test_function_base.py b/numpy/lib/tests/test_function_base.py index 9075ff538c86..f95e0a251680 100644 --- a/numpy/lib/tests/test_function_base.py +++ b/numpy/lib/tests/test_function_base.py @@ -4,7 +4,6 @@ import warnings import sys import decimal -import types from fractions import Fraction import pytest diff --git a/numpy/lib/tests/test_recfunctions.py b/numpy/lib/tests/test_recfunctions.py index fa5f4dec23a9..53229e31a389 100644 --- a/numpy/lib/tests/test_recfunctions.py +++ b/numpy/lib/tests/test_recfunctions.py @@ -772,7 +772,6 @@ def test_join(self): def test_join_subdtype(self): # tests the bug in https://stackoverflow.com/q/44769632/102441 - from numpy.lib import recfunctions as rfn foo = np.array([(1,)], dtype=[('key', int)]) bar = np.array([(1, np.array([1,2,3]))], diff --git a/numpy/lib/tests/test_shape_base.py b/numpy/lib/tests/test_shape_base.py index be1604a754ab..ff9019e3d072 100644 --- a/numpy/lib/tests/test_shape_base.py +++ b/numpy/lib/tests/test_shape_base.py @@ -1,7 +1,6 @@ from __future__ import division, absolute_import, print_function import numpy as np -import warnings import functools import sys import pytest From f33c1d69f0e2a2f3064b014609e67333dd1956c5 Mon Sep 17 00:00:00 2001 From: Charles Harris Date: Wed, 1 Jan 2020 11:13:14 -0700 Subject: [PATCH 0096/4713] REL: Update master after NumPy 1.16.6 and 1.17.5 releases. - Add 1.16.6-changelog.rst - Add 1.17.5-changelog.rst - Add 1.16.6-notes.rst - Add 1.17.5-notes.rst - Update doc/source/release.rst [skip ci] --- doc/changelog/1.16.6-changelog.rst | 36 ++++++++++++ doc/changelog/1.17.5-changelog.rst | 26 +++++++++ doc/source/release.rst | 2 + doc/source/release/1.16.6-notes.rst | 87 +++++++++++++++++++++++++++++ doc/source/release/1.17.5-notes.rst | 45 +++++++++++++++ 5 files changed, 196 insertions(+) create mode 100644 doc/changelog/1.16.6-changelog.rst create mode 100644 doc/changelog/1.17.5-changelog.rst create mode 100644 doc/source/release/1.16.6-notes.rst create mode 100644 doc/source/release/1.17.5-notes.rst diff --git a/doc/changelog/1.16.6-changelog.rst b/doc/changelog/1.16.6-changelog.rst new file mode 100644 index 000000000000..62ff46c34827 --- /dev/null +++ b/doc/changelog/1.16.6-changelog.rst @@ -0,0 +1,36 @@ + +Contributors +============ + +A total of 10 people contributed to this release. + +* CakeWithSteak +* Charles Harris +* Chris Burr +* Eric Wieser +* Fernando Saravia +* Lars Grueter +* Matti Picus +* Maxwell Aladago +* Qiming Sun +* Warren Weckesser + +Pull requests merged +==================== + +A total of 14 pull requests were merged for this release. + +* `#14211 `__: BUG: Fix uint-overflow if padding with linear_ramp and negative... +* `#14275 `__: BUG: fixing to allow unpickling of PY3 pickles from PY2 +* `#14340 `__: BUG: Fix misuse of .names and .fields in various places (backport... +* `#14423 `__: BUG: test, fix regression in converting to ctypes. +* `#14434 `__: BUG: Fixed maximum relative error reporting in assert_allclose +* `#14509 `__: BUG: Fix regression in boolean matmul. +* `#14686 `__: BUG: properly define PyArray_DescrCheck +* `#14853 `__: BLD: add 'apt update' to shippable +* `#14854 `__: BUG: Fix _ctypes class circular reference. (#13808) +* `#14856 `__: BUG: Fix `np.einsum` errors on Power9 Linux and z/Linux +* `#14863 `__: BLD: Prevent -flto from optimising long double representation... +* `#14864 `__: BUG: lib: Fix histogram problem with signed integer arrays. +* `#15172 `__: ENH: Backport improvements to testing functions. +* `#15191 `__: REL: Prepare for 1.16.6 release. diff --git a/doc/changelog/1.17.5-changelog.rst b/doc/changelog/1.17.5-changelog.rst new file mode 100644 index 000000000000..7ac758075110 --- /dev/null +++ b/doc/changelog/1.17.5-changelog.rst @@ -0,0 +1,26 @@ + +Contributors +============ + +A total of 6 people contributed to this release. People with a "+" by their +names contributed a patch for the first time. + +* Charles Harris +* Eric Wieser +* Ilhan Polat +* Matti Picus +* Michael Hudson-Doyle +* Ralf Gommers + +Pull requests merged +==================== + +A total of 7 pull requests were merged for this release. + +* `#14593 `__: MAINT: backport Cython API cleanup to 1.17.x, remove docs +* `#14937 `__: BUG: fix integer size confusion in handling array's ndmin argument +* `#14939 `__: BUILD: remove SSE2 flag from numpy.random builds +* `#14993 `__: MAINT: Added Python3.8 branch to dll lib discovery +* `#15038 `__: BUG: Fix refcounting in ufunc object loops +* `#15067 `__: BUG: Exceptions tracebacks are dropped +* `#15175 `__: ENH: Backport improvements to testing functions. diff --git a/doc/source/release.rst b/doc/source/release.rst index 26373ad07abb..a6fe46782bfa 100644 --- a/doc/source/release.rst +++ b/doc/source/release.rst @@ -7,11 +7,13 @@ Release Notes 1.19.0 1.18.0 + 1.17.5 1.17.4 1.17.3 1.17.2 1.17.1 1.17.0 + 1.16.6 1.16.5 1.16.4 1.16.3 diff --git a/doc/source/release/1.16.6-notes.rst b/doc/source/release/1.16.6-notes.rst new file mode 100644 index 000000000000..0aeba3cd3dd9 --- /dev/null +++ b/doc/source/release/1.16.6-notes.rst @@ -0,0 +1,87 @@ +.. currentmodule:: numpy + +========================== +NumPy 1.16.6 Release Notes +========================== + +The NumPy 1.16.6 release fixes bugs reported against the 1.16.5 release, and +also backports several enhancements from master that seem appropriate for a +release series that is the last to support Python 2.7. The wheels on PyPI are +linked with OpenBLAS v0.3.7, which should fix errors on Skylake series +cpus. + +Downstream developers building this release should use Cython >= 0.29.2 and, if +using OpenBLAS, OpenBLAS >= v0.3.7. The supported Python versions are 2.7 and +3.5-3.7. + +Highlights +========== + +- The ``np.testing.utils`` functions have been updated from 1.19.0-dev0. + This improves the function documentation and error messages as well + extending the ``assert_array_compare`` function to additional types. + + +New functions +============= + +Allow matmul (`@` operator) to work with object arrays. +------------------------------------------------------- +This is an enhancement that was added in NumPy 1.17 and seems reasonable to +include in the LTS 1.16 release series. + + +Compatibility notes +=================== + +Fix regression in matmul (`@` operator) for boolean types +--------------------------------------------------------- +Booleans were being treated as integers rather than booleans, +which was a regression from previous behavior. + + +Improvements +============ + +Array comparison assertions include maximum differences +------------------------------------------------------- +Error messages from array comparison tests such as ``testing.assert_allclose`` +now include "max absolute difference" and "max relative difference," in +addition to the previous "mismatch" percentage. This information makes it +easier to update absolute and relative error tolerances. + +Contributors +============ + +A total of 10 people contributed to this release. + +* CakeWithSteak +* Charles Harris +* Chris Burr +* Eric Wieser +* Fernando Saravia +* Lars Grueter +* Matti Picus +* Maxwell Aladago +* Qiming Sun +* Warren Weckesser + +Pull requests merged +==================== + +A total of 14 pull requests were merged for this release. + +* `#14211 `__: BUG: Fix uint-overflow if padding with linear_ramp and negative... +* `#14275 `__: BUG: fixing to allow unpickling of PY3 pickles from PY2 +* `#14340 `__: BUG: Fix misuse of .names and .fields in various places (backport... +* `#14423 `__: BUG: test, fix regression in converting to ctypes. +* `#14434 `__: BUG: Fixed maximum relative error reporting in assert_allclose +* `#14509 `__: BUG: Fix regression in boolean matmul. +* `#14686 `__: BUG: properly define PyArray_DescrCheck +* `#14853 `__: BLD: add 'apt update' to shippable +* `#14854 `__: BUG: Fix _ctypes class circular reference. (#13808) +* `#14856 `__: BUG: Fix `np.einsum` errors on Power9 Linux and z/Linux +* `#14863 `__: BLD: Prevent -flto from optimising long double representation... +* `#14864 `__: BUG: lib: Fix histogram problem with signed integer arrays. +* `#15172 `__: ENH: Backport improvements to testing functions. +* `#15191 `__: REL: Prepare for 1.16.6 release. diff --git a/doc/source/release/1.17.5-notes.rst b/doc/source/release/1.17.5-notes.rst new file mode 100644 index 000000000000..0f1d3e1a59d5 --- /dev/null +++ b/doc/source/release/1.17.5-notes.rst @@ -0,0 +1,45 @@ +.. currentmodule:: numpy + +========================== +NumPy 1.17.5 Release Notes +========================== + +This release contains fixes for bugs reported against NumPy 1.17.4 along with +some build improvements. The Python versions supported in this release +are 3.5-3.8. + +Downstream developers should use Cython >= 0.29.14 for Python 3.8 support and +OpenBLAS >= 3.7 to avoid errors on the Skylake architecture. + +It is recommended that developers interested in the new random bit generators +upgrade to the NumPy 1.18.x series, as it has updated documentation and +many small improvements. + + +Contributors +============ + +A total of 6 people contributed to this release. People with a "+" by their +names contributed a patch for the first time. + +* Charles Harris +* Eric Wieser +* Ilhan Polat +* Matti Picus +* Michael Hudson-Doyle +* Ralf Gommers + + +Pull requests merged +==================== + +A total of 8 pull requests were merged for this release. + +* `#14593 `__: MAINT: backport Cython API cleanup to 1.17.x, remove docs +* `#14937 `__: BUG: fix integer size confusion in handling array's ndmin argument +* `#14939 `__: BUILD: remove SSE2 flag from numpy.random builds +* `#14993 `__: MAINT: Added Python3.8 branch to dll lib discovery +* `#15038 `__: BUG: Fix refcounting in ufunc object loops +* `#15067 `__: BUG: Exceptions tracebacks are dropped +* `#15175 `__: ENH: Backport improvements to testing functions. +* `#15213 `__: REL: Prepare for the NumPy 1.17.5 release. From bc6d573a58bf8a8f4448f26ed220afff93df7c97 Mon Sep 17 00:00:00 2001 From: Eric Wieser Date: Wed, 1 Jan 2020 19:21:11 +0000 Subject: [PATCH 0097/4713] DEP: records: Deprecate treating shape=0 as shape=None `shape=n` is a shorthand for `shape=(n,)` except in the case when `n==0`, when it is a shorthand for `shape=None`. This special case is dangerous, as it makes `fromrecords(..., shape=len(a))` behave surprisingly when a is an empty sequence. Users impacted by this warning either: * Have a bug in their code, and will need to either: - wait for the deprecation to expire - change their code to use `(len(a),)` instead of `len(a)` * Are using the non-preferred spellling, and will need to replace a literal `0` or `False` with `None` --- .../upcoming_changes/15217.deprecation.rst | 11 ++++++ numpy/core/records.py | 35 +++++++++++++++---- 2 files changed, 40 insertions(+), 6 deletions(-) create mode 100644 doc/release/upcoming_changes/15217.deprecation.rst diff --git a/doc/release/upcoming_changes/15217.deprecation.rst b/doc/release/upcoming_changes/15217.deprecation.rst new file mode 100644 index 000000000000..e9dd0995de49 --- /dev/null +++ b/doc/release/upcoming_changes/15217.deprecation.rst @@ -0,0 +1,11 @@ +Passing ``shape=0`` to factory functions in ``numpy.rec`` is deprecated +----------------------------------------------------------------------- + +``0`` is treated as a special case by these functions, which aliases to +``None``. In future, ``0`` will not be a special case, and will be treated +as an array length like any other integer is. The affected functions are: + +* `numpy.core.records.fromarrays` +* `numpy.core.records.fromrecords` +* `numpy.core.records.fromstring` +* `numpy.core.records.fromfile` diff --git a/numpy/core/records.py b/numpy/core/records.py index a1cad9075629..7cc47e319b2b 100644 --- a/numpy/core/records.py +++ b/numpy/core/records.py @@ -583,6 +583,18 @@ def field(self, attr, val=None): return self.setfield(val, *res) +def _deprecate_shape_0_as_None(shape): + if shape == 0: + warnings.warn( + "Passing `shape=0` to have the shape be inferred is deprecated, " + "and in future will be equivalent to `shape=(0,)`. To infer " + "the shape and suppress this warning, pass `shape=None` instead.", + FutureWarning, stacklevel=3) + return None + else: + return shape + + def fromarrays(arrayList, dtype=None, shape=None, formats=None, names=None, titles=None, aligned=False, byteorder=None): """ create a record array from a (flat) list of arrays @@ -600,10 +612,12 @@ def fromarrays(arrayList, dtype=None, shape=None, formats=None, arrayList = [sb.asarray(x) for x in arrayList] - if shape is None or shape == 0: - shape = arrayList[0].shape + # NumPy 1.19.0, 2020-01-01 + shape = _deprecate_shape_0_as_None(shape) - if isinstance(shape, int): + if shape is None: + shape = arrayList[0].shape + elif isinstance(shape, int): shape = (shape,) if formats is None and dtype is None: @@ -689,7 +703,9 @@ def fromrecords(recList, dtype=None, shape=None, formats=None, names=None, try: retval = sb.array(recList, dtype=descr) except (TypeError, ValueError): - if (shape is None or shape == 0): + # NumPy 1.19.0, 2020-01-01 + shape = _deprecate_shape_0_as_None(shape) + if shape is None: shape = len(recList) if isinstance(shape, (int, long)): shape = (shape,) @@ -728,7 +744,11 @@ def fromstring(datastring, dtype=None, shape=None, offset=0, formats=None, descr = format_parser(formats, names, titles, aligned, byteorder)._descr itemsize = descr.itemsize - if (shape is None or shape == 0 or shape == -1): + + # NumPy 1.19.0, 2020-01-01 + shape = _deprecate_shape_0_as_None(shape) + + if shape is None or shape == -1: shape = (len(datastring) - offset) // itemsize _array = recarray(shape, descr, buf=datastring, offset=offset) @@ -771,7 +791,10 @@ def fromfile(fd, dtype=None, shape=None, offset=0, formats=None, if dtype is None and formats is None: raise TypeError("fromfile() needs a 'dtype' or 'formats' argument") - if (shape is None or shape == 0): + # NumPy 1.19.0, 2020-01-01 + shape = _deprecate_shape_0_as_None(shape) + + if shape is None: shape = (-1,) elif isinstance(shape, (int, long)): shape = (shape,) From daa63afdbaf59a281b680668c2fdbaac1ca49f04 Mon Sep 17 00:00:00 2001 From: Pauli Virtanen Date: Wed, 1 Jan 2020 21:05:27 +0200 Subject: [PATCH 0098/4713] DOC: lapack_lite: fix incorrect information in lapack_lite README --- numpy/linalg/lapack_lite/README.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/numpy/linalg/lapack_lite/README.rst b/numpy/linalg/lapack_lite/README.rst index 1343d25f8a94..ba30aa4ed5b9 100644 --- a/numpy/linalg/lapack_lite/README.rst +++ b/numpy/linalg/lapack_lite/README.rst @@ -18,9 +18,9 @@ and is unlikely to ever be ported to python 3. The routines that ``lapack_litemodule.c`` wraps are listed in ``wrapped_routines``, along with a few exceptions that aren't picked up properly. Assuming that you have an unpacked LAPACK source tree in -``~/LAPACK``, you generate the new routines in a directory ``new-lite/`` with:: +``~/LAPACK``, you generate the new routines in this directory with:: -$ python2 ./make_lite.py wrapped_routines ~/LAPACK new-lite/ +$ python2 ./make_lite.py wrapped_routines ~/LAPACK This will grab the right routines, with dependencies, put them into the appropriate ``f2c_*.f`` files, run ``f2c`` over them, then do some scrubbing From 0159b84141a827e9e96df7ddf25c32c6df8dfb6d Mon Sep 17 00:00:00 2001 From: Pauli Virtanen Date: Wed, 1 Jan 2020 21:28:48 +0200 Subject: [PATCH 0099/4713] ENH: build fallback lapack_lite with 64-bit integers on 64-bit platforms Build the lapack fallback library (used when no LAPACK installed) with 64-bit integer size when building on a 64-bit platform. --- numpy/linalg/lapack_lite/f2c.h | 14 ++++++++------ numpy/linalg/setup.py | 4 ++++ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/numpy/linalg/lapack_lite/f2c.h b/numpy/linalg/lapack_lite/f2c.h index 80f1a12b19df..4462eaa74bf3 100644 --- a/numpy/linalg/lapack_lite/f2c.h +++ b/numpy/linalg/lapack_lite/f2c.h @@ -8,15 +8,17 @@ #define F2C_INCLUDE #include +#include "numpy/npy_common.h" +#include "npy_cblas.h" -typedef int integer; +typedef CBLAS_INT integer; typedef char *address; typedef short int shortint; typedef float real; typedef double doublereal; typedef struct { real r, i; } complex; typedef struct { doublereal r, i; } doublecomplex; -typedef int logical; +typedef CBLAS_INT logical; typedef short int shortlogical; typedef char logical1; typedef char integer1; @@ -37,9 +39,9 @@ typedef short flag; typedef short ftnlen; typedef short ftnint; #else -typedef int flag; -typedef int ftnlen; -typedef int ftnint; +typedef CBLAS_INT flag; +typedef CBLAS_INT ftnlen; +typedef CBLAS_INT ftnint; #endif /*external read, write*/ @@ -352,7 +354,7 @@ extern void s_copy(char *, char *, ftnlen, ftnlen); extern int s_paus(char *, ftnlen); extern integer s_rdfe(cilist *); extern integer s_rdue(cilist *); -extern integer s_rnge(char *, integer, char *, integer); +extern int s_rnge(char *, int, char *, int); extern integer s_rsfe(cilist *); extern integer s_rsfi(icilist *); extern integer s_rsle(cilist *); diff --git a/numpy/linalg/setup.py b/numpy/linalg/setup.py index 6315a34b41d0..bfc0203d2c67 100644 --- a/numpy/linalg/setup.py +++ b/numpy/linalg/setup.py @@ -31,6 +31,10 @@ def configuration(parent_package='', top_path=None): else: lapack_info = get_info('lapack_opt', 0) # and {} + if not lapack_info and sys.maxsize > 2**32: + # Build lapack-lite in 64-bit integer mode + config.add_define_macros([('HAVE_BLAS_ILP64', None)]) + def get_lapack_lite_sources(ext, build_dir): if not lapack_info: print("### Warning: Using unoptimized lapack ###") From 60a3eb49e1971e19c56357a2da5b429ab7c974ec Mon Sep 17 00:00:00 2001 From: Pauli Virtanen Date: Wed, 1 Jan 2020 21:34:22 +0200 Subject: [PATCH 0100/4713] MAINT: better way of indicating whether numpy was built with ILP64 BLAS --- numpy/linalg/lapack_litemodule.c | 6 ++++++ numpy/testing/_private/utils.py | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/numpy/linalg/lapack_litemodule.c b/numpy/linalg/lapack_litemodule.c index 4c80317f556b..56f38364f393 100644 --- a/numpy/linalg/lapack_litemodule.c +++ b/numpy/linalg/lapack_litemodule.c @@ -416,5 +416,11 @@ initlapack_lite(void) LapackError = PyErr_NewException("lapack_lite.LapackError", NULL, NULL); PyDict_SetItemString(d, "LapackError", LapackError); +#ifdef HAVE_BLAS_ILP64 + PyDict_SetItemString(d, "_ilp64", Py_True); +#else + PyDict_SetItemString(d, "_ilp64", Py_False); +#endif + return RETVAL(m); } diff --git a/numpy/testing/_private/utils.py b/numpy/testing/_private/utils.py index 23267a9e1f72..94bad4f637b0 100644 --- a/numpy/testing/_private/utils.py +++ b/numpy/testing/_private/utils.py @@ -21,7 +21,7 @@ from numpy.core import( intp, float32, empty, arange, array_repr, ndarray, isnat, array) -import numpy.__config__ +import numpy.linalg.lapack_lite if sys.version_info[0] >= 3: from io import StringIO @@ -54,7 +54,7 @@ class KnownFailureException(Exception): IS_PYPY = platform.python_implementation() == 'PyPy' HAS_REFCOUNT = getattr(sys, 'getrefcount', None) is not None -HAS_LAPACK64 = hasattr(numpy.__config__, 'lapack_ilp64_opt_info') +HAS_LAPACK64 = numpy.linalg.lapack_lite._ilp64 def import_nose(): From df5ba1ff3e6e9f9db54a55952d5590f45f8b5b36 Mon Sep 17 00:00:00 2001 From: Pauli Virtanen Date: Wed, 1 Jan 2020 22:26:47 +0200 Subject: [PATCH 0101/4713] MAINT: indicate in numpy.__config__ when fallback lapack_lite is used Make numpy.__config__.show() to print information about the fallback lapack_lite library when it is used. --- numpy/linalg/setup.py | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/numpy/linalg/setup.py b/numpy/linalg/setup.py index bfc0203d2c67..0aa0566d6ff6 100644 --- a/numpy/linalg/setup.py +++ b/numpy/linalg/setup.py @@ -5,7 +5,7 @@ def configuration(parent_package='', top_path=None): from numpy.distutils.misc_util import Configuration - from numpy.distutils.system_info import get_info + from numpy.distutils.system_info import get_info, system_info config = Configuration('linalg', parent_package, top_path) config.add_data_dir('tests') @@ -31,12 +31,23 @@ def configuration(parent_package='', top_path=None): else: lapack_info = get_info('lapack_opt', 0) # and {} - if not lapack_info and sys.maxsize > 2**32: - # Build lapack-lite in 64-bit integer mode - config.add_define_macros([('HAVE_BLAS_ILP64', None)]) + use_lapack_lite = not lapack_info + + if use_lapack_lite: + # This makes numpy.distutils write the fact that lapack_lite + # is being used to numpy.__config__ + class numpy_linalg_lapack_lite(system_info): + def calc_info(self): + info = {'language': 'c'} + if sys.maxsize > 2**32: + # Build lapack-lite in 64-bit integer mode + info['define_macros'] = [('HAVE_BLAS_ILP64', None)] + self.set_info(**info) + + lapack_info = numpy_linalg_lapack_lite().get_info(2) def get_lapack_lite_sources(ext, build_dir): - if not lapack_info: + if use_lapack_lite: print("### Warning: Using unoptimized lapack ###") return all_sources else: From a1d1e36f96c843e90348c4ff4cca6657d1a71b0e Mon Sep 17 00:00:00 2001 From: Pauli Virtanen Date: Wed, 1 Jan 2020 23:40:49 +0200 Subject: [PATCH 0102/4713] DOC: add release note for 64-bit lapack_lite --- doc/release/upcoming_changes/15218.improvement.rst | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 doc/release/upcoming_changes/15218.improvement.rst diff --git a/doc/release/upcoming_changes/15218.improvement.rst b/doc/release/upcoming_changes/15218.improvement.rst new file mode 100644 index 000000000000..ccbbbd66f516 --- /dev/null +++ b/doc/release/upcoming_changes/15218.improvement.rst @@ -0,0 +1,6 @@ +Use 64-bit integer size on 64-bit platforms in fallback lapack_lite +------------------------------------------------------------------- + +Use 64-bit integer size on 64-bit platforms in the fallback LAPACK library, +which is used when the system has no LAPACK installed, allowing it to deal with +linear algebra for large arrays. From 0fea57e2c3c890b63c91325f9f9ce07ead74b745 Mon Sep 17 00:00:00 2001 From: Warren Weckesser Date: Tue, 31 Dec 2019 09:57:58 -0500 Subject: [PATCH 0103/4713] BUG: lib: Fix handling of integer arrays by gradient. In numpy.gradient, convert integer array inputs to float64 to avoid unwanted modular arithmetic. Closes gh-15207. --- numpy/lib/function_base.py | 17 ++++++++++---- numpy/lib/tests/test_function_base.py | 34 +++++++++++++++++++++++++++ 2 files changed, 47 insertions(+), 4 deletions(-) diff --git a/numpy/lib/function_base.py b/numpy/lib/function_base.py index c2680b016fe9..4c3de4df9941 100644 --- a/numpy/lib/function_base.py +++ b/numpy/lib/function_base.py @@ -974,13 +974,18 @@ def gradient(f, *varargs, **kwargs): # scalar or 1d array for each axis dx = list(varargs) for i, distances in enumerate(dx): - if np.ndim(distances) == 0: + distances = np.asanyarray(distances) + if distances.ndim == 0: continue - elif np.ndim(distances) != 1: + elif distances.ndim != 1: raise ValueError("distances must be either scalars or 1d") if len(distances) != f.shape[axes[i]]: raise ValueError("when 1d, distances must match " "the length of the corresponding dimension") + if np.issubdtype(distances.dtype, np.integer): + # Convert numpy integer types to float64 to avoid modular + # arithmetic in np.diff(distances). + distances = distances.astype(np.float64) diffx = np.diff(distances) # if distances are constant reduce to the scalar case # since it brings a consistent speedup @@ -1019,8 +1024,12 @@ def gradient(f, *varargs, **kwargs): elif np.issubdtype(otype, np.inexact): pass else: - # all other types convert to floating point - otype = np.double + # All other types convert to floating point. + # First check if f is a numpy integer type; if so, convert f to float64 + # to avoid modular arithmetic when computing the changes in f. + if np.issubdtype(otype, np.integer): + f = f.astype(np.float64) + otype = np.float64 for axis, ax_dx in zip(axes, dx): if f.shape[axis] < edge_order + 1: diff --git a/numpy/lib/tests/test_function_base.py b/numpy/lib/tests/test_function_base.py index f95e0a251680..77e8f03f9a24 100644 --- a/numpy/lib/tests/test_function_base.py +++ b/numpy/lib/tests/test_function_base.py @@ -1083,6 +1083,40 @@ def test_values(self): assert_raises(ValueError, gradient, np.arange(1), edge_order=2) assert_raises(ValueError, gradient, np.arange(2), edge_order=2) + @pytest.mark.parametrize('f_dtype', [np.uint8, np.uint16, + np.uint32, np.uint64]) + def test_f_decreasing_unsigned_int(self, f_dtype): + f = np.array([5, 4, 3, 2, 1], dtype=f_dtype) + g = gradient(f) + assert_array_equal(g, [-1]*len(f)) + + @pytest.mark.parametrize('f_dtype', [np.int8, np.int16, + np.int32, np.int64]) + def test_f_signed_int_big_jump(self, f_dtype): + maxint = np.iinfo(f_dtype).max + x = np.array([1, 3]) + f = np.array([-1, maxint], dtype=f_dtype) + dfdx = gradient(f, x) + assert_array_equal(dfdx, [(maxint + 1) // 2]*2) + + @pytest.mark.parametrize('x_dtype', [np.uint8, np.uint16, + np.uint32, np.uint64]) + def test_x_decreasing_unsigned(self, x_dtype): + x = np.array([3, 2, 1], dtype=x_dtype) + f = np.array([0, 2, 4]) + dfdx = gradient(f, x) + assert_array_equal(dfdx, [-2]*len(x)) + + @pytest.mark.parametrize('x_dtype', [np.int8, np.int16, + np.int32, np.int64]) + def test_x_signed_int_big_jump(self, x_dtype): + minint = np.iinfo(x_dtype).min + maxint = np.iinfo(x_dtype).max + x = np.array([-1, maxint], dtype=x_dtype) + f = np.array([minint // 2, 0]) + dfdx = gradient(f, x) + assert_array_equal(dfdx, [0.5, 0.5]) + class TestAngle(object): From 5d1a742d9ba9acd6331566db4ae204019bdbca1d Mon Sep 17 00:00:00 2001 From: mattip Date: Fri, 3 Jan 2020 13:51:20 +0200 Subject: [PATCH 0104/4713] DOC: typo in release.rst --- doc/source/release.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/source/release.rst b/doc/source/release.rst index a6fe46782bfa..9679ec6c8fbf 100644 --- a/doc/source/release.rst +++ b/doc/source/release.rst @@ -7,13 +7,13 @@ Release Notes 1.19.0 1.18.0 - 1.17.5 + 1.17.5 1.17.4 1.17.3 1.17.2 1.17.1 1.17.0 - 1.16.6 + 1.16.6 1.16.5 1.16.4 1.16.3 From ed1e9659f103260a32536b4a7615393e3b1173dc Mon Sep 17 00:00:00 2001 From: Jon Dufresne Date: Tue, 27 Aug 2019 04:36:38 -0700 Subject: [PATCH 0105/4713] MAINT: Remove unnecessary 'from __future__ import ...' statements As numpy is Python 3 only, these import statements are now unnecessary and don't alter runtime behavior. --- azure-steps-windows.yml | 4 ++-- benchmarks/benchmarks/__init__.py | 2 -- benchmarks/benchmarks/bench_app.py | 2 -- benchmarks/benchmarks/bench_avx.py | 3 --- benchmarks/benchmarks/bench_core.py | 2 -- benchmarks/benchmarks/bench_function_base.py | 2 -- benchmarks/benchmarks/bench_import.py | 2 -- benchmarks/benchmarks/bench_indexing.py | 2 -- benchmarks/benchmarks/bench_io.py | 2 -- benchmarks/benchmarks/bench_lib.py | 2 -- benchmarks/benchmarks/bench_linalg.py | 2 -- benchmarks/benchmarks/bench_ma.py | 2 -- benchmarks/benchmarks/bench_overrides.py | 2 -- benchmarks/benchmarks/bench_random.py | 2 -- benchmarks/benchmarks/bench_records.py | 1 - benchmarks/benchmarks/bench_reduce.py | 2 -- benchmarks/benchmarks/bench_shape_base.py | 2 -- benchmarks/benchmarks/bench_ufunc.py | 2 -- benchmarks/benchmarks/common.py | 2 -- doc/DISTUTILS.rst.txt | 3 --- doc/cdoc/numpyfilter.py | 2 -- doc/example.py | 2 -- doc/postprocess.py | 2 -- doc/source/conf.py | 2 -- doc/source/f2py/setup_example.py | 2 -- doc/source/reference/arrays.ndarray.rst | 4 ---- doc/summarize.py | 2 -- numpy/__init__.py | 2 -- numpy/_build_utils/__init__.py | 1 - numpy/_build_utils/apple_accelerate.py | 2 -- numpy/_globals.py | 2 -- numpy/_pytesttester.py | 2 -- numpy/compat/__init__.py | 2 -- numpy/compat/_inspect.py | 2 -- numpy/compat/setup.py | 2 -- numpy/compat/tests/test_compat.py | 2 -- numpy/conftest.py | 2 -- numpy/core/__init__.py | 2 -- numpy/core/_add_newdocs.py | 2 -- numpy/core/_asarray.py | 2 -- numpy/core/_dtype.py | 2 -- numpy/core/_internal.py | 2 -- numpy/core/_methods.py | 2 -- numpy/core/_ufunc_config.py | 4 ---- numpy/core/arrayprint.py | 2 -- numpy/core/code_generators/__init__.py | 1 - numpy/core/code_generators/genapi.py | 2 -- numpy/core/code_generators/generate_numpy_api.py | 2 -- numpy/core/code_generators/generate_ufunc_api.py | 2 -- numpy/core/code_generators/generate_umath.py | 2 -- numpy/core/code_generators/numpy_api.py | 2 -- numpy/core/code_generators/ufunc_docstrings.py | 9 +-------- numpy/core/cversions.py | 2 -- numpy/core/defchararray.py | 2 -- numpy/core/einsumfunc.py | 2 -- numpy/core/fromnumeric.py | 2 -- numpy/core/function_base.py | 2 -- numpy/core/getlimits.py | 2 -- numpy/core/machar.py | 2 -- numpy/core/memmap.py | 2 -- numpy/core/numeric.py | 2 -- numpy/core/numerictypes.py | 2 -- numpy/core/records.py | 2 -- numpy/core/setup.py | 2 -- numpy/core/setup_common.py | 2 -- numpy/core/shape_base.py | 2 -- numpy/core/tests/_locales.py | 2 -- numpy/core/tests/test_abc.py | 2 -- numpy/core/tests/test_api.py | 2 -- numpy/core/tests/test_arrayprint.py | 2 -- numpy/core/tests/test_datetime.py | 2 -- numpy/core/tests/test_defchararray.py | 2 -- numpy/core/tests/test_deprecations.py | 2 -- numpy/core/tests/test_dtype.py | 2 -- numpy/core/tests/test_einsum.py | 2 -- numpy/core/tests/test_errstate.py | 2 -- numpy/core/tests/test_extint128.py | 2 -- numpy/core/tests/test_function_base.py | 2 -- numpy/core/tests/test_getlimits.py | 2 -- numpy/core/tests/test_half.py | 2 -- numpy/core/tests/test_indexerrors.py | 2 -- numpy/core/tests/test_indexing.py | 2 -- numpy/core/tests/test_item_selection.py | 2 -- numpy/core/tests/test_longdouble.py | 2 -- numpy/core/tests/test_machar.py | 2 -- numpy/core/tests/test_mem_overlap.py | 2 -- numpy/core/tests/test_memmap.py | 2 -- numpy/core/tests/test_multiarray.py | 2 -- numpy/core/tests/test_nditer.py | 2 -- numpy/core/tests/test_numeric.py | 2 -- numpy/core/tests/test_numerictypes.py | 2 -- numpy/core/tests/test_overrides.py | 2 -- numpy/core/tests/test_print.py | 2 -- numpy/core/tests/test_records.py | 2 -- numpy/core/tests/test_regression.py | 2 -- numpy/core/tests/test_scalar_ctors.py | 2 -- numpy/core/tests/test_scalar_methods.py | 2 -- numpy/core/tests/test_scalarinherit.py | 2 -- numpy/core/tests/test_scalarmath.py | 2 -- numpy/core/tests/test_scalarprint.py | 2 -- numpy/core/tests/test_shape_base.py | 2 -- numpy/core/tests/test_ufunc.py | 2 -- numpy/core/tests/test_umath.py | 2 -- numpy/core/tests/test_umath_complex.py | 2 -- numpy/core/tests/test_unicode.py | 2 -- numpy/core/umath_tests.py | 2 -- numpy/ctypeslib.py | 2 -- numpy/distutils/__init__.py | 2 -- numpy/distutils/ccompiler.py | 2 -- numpy/distutils/command/__init__.py | 2 -- numpy/distutils/command/autodist.py | 2 -- numpy/distutils/command/bdist_rpm.py | 2 -- numpy/distutils/command/build.py | 2 -- numpy/distutils/command/build_clib.py | 2 -- numpy/distutils/command/build_ext.py | 2 -- numpy/distutils/command/build_py.py | 2 -- numpy/distutils/command/build_scripts.py | 2 -- numpy/distutils/command/build_src.py | 2 -- numpy/distutils/command/config.py | 2 -- numpy/distutils/command/config_compiler.py | 2 -- numpy/distutils/command/develop.py | 2 -- numpy/distutils/command/egg_info.py | 2 -- numpy/distutils/command/install.py | 2 -- numpy/distutils/command/install_clib.py | 2 -- numpy/distutils/command/install_data.py | 2 -- numpy/distutils/command/install_headers.py | 2 -- numpy/distutils/command/sdist.py | 2 -- numpy/distutils/compat.py | 2 -- numpy/distutils/conv_template.py | 2 -- numpy/distutils/core.py | 2 -- numpy/distutils/cpuinfo.py | 2 -- numpy/distutils/exec_command.py | 2 -- numpy/distutils/extension.py | 2 -- numpy/distutils/fcompiler/__init__.py | 2 -- numpy/distutils/fcompiler/absoft.py | 2 -- numpy/distutils/fcompiler/compaq.py | 2 -- numpy/distutils/fcompiler/environment.py | 2 -- numpy/distutils/fcompiler/g95.py | 2 -- numpy/distutils/fcompiler/gnu.py | 2 -- numpy/distutils/fcompiler/hpux.py | 2 -- numpy/distutils/fcompiler/ibm.py | 2 -- numpy/distutils/fcompiler/intel.py | 2 -- numpy/distutils/fcompiler/lahey.py | 2 -- numpy/distutils/fcompiler/mips.py | 2 -- numpy/distutils/fcompiler/nag.py | 2 -- numpy/distutils/fcompiler/none.py | 2 -- numpy/distutils/fcompiler/pathf95.py | 2 -- numpy/distutils/fcompiler/pg.py | 2 -- numpy/distutils/fcompiler/sun.py | 2 -- numpy/distutils/fcompiler/vast.py | 2 -- numpy/distutils/from_template.py | 2 -- numpy/distutils/intelccompiler.py | 2 -- numpy/distutils/lib2def.py | 2 -- numpy/distutils/line_endings.py | 2 -- numpy/distutils/log.py | 2 -- numpy/distutils/mingw32ccompiler.py | 2 -- numpy/distutils/misc_util.py | 2 -- numpy/distutils/msvc9compiler.py | 2 -- numpy/distutils/msvccompiler.py | 2 -- numpy/distutils/npy_pkg_config.py | 2 -- numpy/distutils/numpy_distribution.py | 2 -- numpy/distutils/pathccompiler.py | 2 -- numpy/distutils/setup.py | 2 -- numpy/distutils/system_info.py | 2 -- numpy/distutils/tests/test_ccompiler.py | 2 -- numpy/distutils/tests/test_exec_command.py | 2 -- numpy/distutils/tests/test_fcompiler.py | 2 -- numpy/distutils/tests/test_fcompiler_gnu.py | 2 -- numpy/distutils/tests/test_fcompiler_intel.py | 2 -- numpy/distutils/tests/test_fcompiler_nagfor.py | 2 -- numpy/distutils/tests/test_misc_util.py | 2 -- numpy/distutils/tests/test_npy_pkg_config.py | 2 -- numpy/distutils/tests/test_shell_utils.py | 2 -- numpy/distutils/tests/test_system_info.py | 2 -- numpy/distutils/unixccompiler.py | 2 -- numpy/doc/__init__.py | 2 -- numpy/doc/basics.py | 1 - numpy/doc/broadcasting.py | 1 - numpy/doc/byteswapping.py | 1 - numpy/doc/constants.py | 2 -- numpy/doc/creation.py | 1 - numpy/doc/glossary.py | 1 - numpy/doc/indexing.py | 1 - numpy/doc/internals.py | 1 - numpy/doc/misc.py | 1 - numpy/doc/structured_arrays.py | 1 - numpy/doc/subclassing.py | 1 - numpy/doc/ufuncs.py | 1 - numpy/dual.py | 2 -- numpy/f2py/__init__.py | 2 -- numpy/f2py/__main__.py | 2 -- numpy/f2py/__version__.py | 2 -- numpy/f2py/auxfuncs.py | 2 -- numpy/f2py/capi_maps.py | 2 -- numpy/f2py/cb_rules.py | 2 -- numpy/f2py/cfuncs.py | 2 -- numpy/f2py/common_rules.py | 2 -- numpy/f2py/crackfortran.py | 2 -- numpy/f2py/diagnose.py | 2 -- numpy/f2py/f2py2e.py | 2 -- numpy/f2py/f2py_testing.py | 2 -- numpy/f2py/f90mod_rules.py | 2 -- numpy/f2py/func2subr.py | 2 -- numpy/f2py/rules.py | 2 -- numpy/f2py/setup.py | 2 -- numpy/f2py/tests/test_array_from_pyobj.py | 2 -- numpy/f2py/tests/test_assumed_shape.py | 2 -- numpy/f2py/tests/test_block_docstring.py | 2 -- numpy/f2py/tests/test_callback.py | 2 -- numpy/f2py/tests/test_common.py | 2 -- numpy/f2py/tests/test_compile_function.py | 2 -- numpy/f2py/tests/test_crackfortran.py | 3 --- numpy/f2py/tests/test_kind.py | 2 -- numpy/f2py/tests/test_mixed.py | 2 -- numpy/f2py/tests/test_parameter.py | 2 -- numpy/f2py/tests/test_quoted_character.py | 2 -- numpy/f2py/tests/test_regression.py | 2 -- numpy/f2py/tests/test_return_character.py | 2 -- numpy/f2py/tests/test_return_complex.py | 2 -- numpy/f2py/tests/test_return_integer.py | 2 -- numpy/f2py/tests/test_return_logical.py | 2 -- numpy/f2py/tests/test_return_real.py | 2 -- numpy/f2py/tests/test_semicolon_split.py | 2 -- numpy/f2py/tests/test_size.py | 2 -- numpy/f2py/tests/test_string.py | 2 -- numpy/f2py/tests/util.py | 2 -- numpy/f2py/use_rules.py | 2 -- numpy/fft/__init__.py | 2 -- numpy/fft/_pocketfft.py | 2 -- numpy/fft/helper.py | 2 -- numpy/fft/setup.py | 2 -- numpy/fft/tests/test_helper.py | 1 - numpy/fft/tests/test_pocketfft.py | 2 -- numpy/lib/__init__.py | 2 -- numpy/lib/_datasource.py | 2 -- numpy/lib/_iotools.py | 2 -- numpy/lib/_version.py | 2 -- numpy/lib/arraypad.py | 2 -- numpy/lib/arraysetops.py | 2 -- numpy/lib/arrayterator.py | 2 -- numpy/lib/financial.py | 2 -- numpy/lib/format.py | 2 -- numpy/lib/function_base.py | 2 -- numpy/lib/histograms.py | 2 -- numpy/lib/index_tricks.py | 2 -- numpy/lib/mixins.py | 2 -- numpy/lib/nanfunctions.py | 2 -- numpy/lib/npyio.py | 2 -- numpy/lib/polynomial.py | 2 -- numpy/lib/recfunctions.py | 2 -- numpy/lib/scimath.py | 2 -- numpy/lib/setup.py | 2 -- numpy/lib/shape_base.py | 2 -- numpy/lib/stride_tricks.py | 2 -- numpy/lib/tests/test__datasource.py | 2 -- numpy/lib/tests/test__iotools.py | 2 -- numpy/lib/tests/test__version.py | 2 -- numpy/lib/tests/test_arraypad.py | 2 -- numpy/lib/tests/test_arraysetops.py | 2 -- numpy/lib/tests/test_arrayterator.py | 2 -- numpy/lib/tests/test_financial.py | 2 -- numpy/lib/tests/test_format.py | 2 -- numpy/lib/tests/test_function_base.py | 2 -- numpy/lib/tests/test_histograms.py | 2 -- numpy/lib/tests/test_index_tricks.py | 2 -- numpy/lib/tests/test_io.py | 2 -- numpy/lib/tests/test_mixins.py | 2 -- numpy/lib/tests/test_nanfunctions.py | 2 -- numpy/lib/tests/test_packbits.py | 2 -- numpy/lib/tests/test_polynomial.py | 2 -- numpy/lib/tests/test_recfunctions.py | 2 -- numpy/lib/tests/test_regression.py | 2 -- numpy/lib/tests/test_shape_base.py | 2 -- numpy/lib/tests/test_stride_tricks.py | 2 -- numpy/lib/tests/test_twodim_base.py | 2 -- numpy/lib/tests/test_type_check.py | 2 -- numpy/lib/tests/test_ufunclike.py | 2 -- numpy/lib/tests/test_utils.py | 2 -- numpy/lib/twodim_base.py | 2 -- numpy/lib/type_check.py | 1 - numpy/lib/ufunclike.py | 2 -- numpy/lib/user_array.py | 2 -- numpy/lib/utils.py | 2 -- numpy/linalg/__init__.py | 2 -- numpy/linalg/lapack_lite/clapack_scrub.py | 2 -- numpy/linalg/lapack_lite/fortran.py | 2 -- numpy/linalg/lapack_lite/make_lite.py | 2 -- numpy/linalg/linalg.py | 2 -- numpy/linalg/setup.py | 2 -- numpy/linalg/tests/test_build.py | 2 -- numpy/linalg/tests/test_deprecations.py | 2 -- numpy/linalg/tests/test_linalg.py | 2 -- numpy/linalg/tests/test_regression.py | 2 -- numpy/ma/__init__.py | 2 -- numpy/ma/bench.py | 2 -- numpy/ma/core.py | 2 -- numpy/ma/extras.py | 2 -- numpy/ma/mrecords.py | 2 -- numpy/ma/setup.py | 2 -- numpy/ma/tests/test_core.py | 2 -- numpy/ma/tests/test_deprecations.py | 2 -- numpy/ma/tests/test_extras.py | 2 -- numpy/ma/tests/test_mrecords.py | 2 -- numpy/ma/tests/test_old_ma.py | 2 -- numpy/ma/tests/test_regression.py | 2 -- numpy/ma/tests/test_subclassing.py | 2 -- numpy/ma/testutils.py | 2 -- numpy/ma/timer_comparison.py | 2 -- numpy/matlib.py | 2 -- numpy/matrixlib/__init__.py | 2 -- numpy/matrixlib/defmatrix.py | 2 -- numpy/matrixlib/setup.py | 2 -- numpy/matrixlib/tests/test_defmatrix.py | 2 -- numpy/matrixlib/tests/test_interaction.py | 2 -- numpy/matrixlib/tests/test_masked_matrix.py | 2 -- numpy/matrixlib/tests/test_matrix_linalg.py | 2 -- numpy/matrixlib/tests/test_multiarray.py | 2 -- numpy/matrixlib/tests/test_numeric.py | 2 -- numpy/matrixlib/tests/test_regression.py | 2 -- numpy/polynomial/__init__.py | 2 -- numpy/polynomial/_polybase.py | 2 -- numpy/polynomial/chebyshev.py | 2 -- numpy/polynomial/hermite.py | 2 -- numpy/polynomial/hermite_e.py | 2 -- numpy/polynomial/laguerre.py | 2 -- numpy/polynomial/legendre.py | 2 -- numpy/polynomial/polynomial.py | 2 -- numpy/polynomial/polyutils.py | 2 -- numpy/polynomial/setup.py | 2 -- numpy/polynomial/tests/test_chebyshev.py | 2 -- numpy/polynomial/tests/test_classes.py | 2 -- numpy/polynomial/tests/test_hermite.py | 2 -- numpy/polynomial/tests/test_hermite_e.py | 2 -- numpy/polynomial/tests/test_laguerre.py | 2 -- numpy/polynomial/tests/test_legendre.py | 2 -- numpy/polynomial/tests/test_polynomial.py | 2 -- numpy/polynomial/tests/test_polyutils.py | 2 -- numpy/polynomial/tests/test_printing.py | 2 -- numpy/random/__init__.py | 2 -- numpy/random/setup.py | 2 -- numpy/random/tests/test_random.py | 1 - numpy/random/tests/test_regression.py | 2 -- numpy/setup.py | 2 -- numpy/testing/__init__.py | 2 -- numpy/testing/_private/decorators.py | 2 -- numpy/testing/_private/noseclasses.py | 2 -- numpy/testing/_private/nosetester.py | 2 -- numpy/testing/_private/utils.py | 2 -- numpy/testing/print_coercion_tables.py | 2 -- numpy/testing/setup.py | 2 -- numpy/testing/tests/test_decorators.py | 2 -- numpy/testing/tests/test_doctesting.py | 2 -- numpy/testing/tests/test_utils.py | 2 -- numpy/testing/utils.py | 2 -- numpy/tests/test_ctypeslib.py | 2 -- numpy/tests/test_matlib.py | 2 -- numpy/tests/test_numpy_version.py | 2 -- numpy/tests/test_public_api.py | 2 -- numpy/tests/test_reloading.py | 2 -- numpy/tests/test_scripts.py | 2 -- numpy/tests/test_warnings.py | 2 -- pavement.py | 2 -- runtests.py | 2 -- setup.py | 2 -- tools/allocation_tracking/setup.py | 2 -- tools/allocation_tracking/track_allocations.py | 2 -- tools/c_coverage/c_coverage_report.py | 2 -- tools/changelog.py | 2 -- tools/commitstats.py | 2 -- tools/cythonize.py | 2 -- tools/find_deprecated_escaped_characters.py | 2 -- tools/npy_tempita/__init__.py | 2 -- tools/npy_tempita/_looper.py | 2 -- tools/npy_tempita/compat3.py | 2 -- tools/openblas_support.py | 1 - tools/refguide_check.py | 2 -- tools/swig/test/setup.py | 2 -- tools/swig/test/testArray.py | 2 -- tools/swig/test/testFarray.py | 2 -- tools/swig/test/testFlat.py | 2 -- tools/swig/test/testFortran.py | 2 -- tools/swig/test/testMatrix.py | 2 -- tools/swig/test/testSuperTensor.py | 2 -- tools/swig/test/testTensor.py | 2 -- tools/swig/test/testVector.py | 2 -- 385 files changed, 3 insertions(+), 765 deletions(-) diff --git a/azure-steps-windows.yml b/azure-steps-windows.yml index f17039455743..fdc9698908bf 100644 --- a/azure-steps-windows.yml +++ b/azure-steps-windows.yml @@ -9,7 +9,7 @@ steps: - script: python -m pip install -r test_requirements.txt displayName: 'Install dependencies; some are optional to avoid test skips' - powershell: | - $pyversion = python -c "from __future__ import print_function; import sys; print(sys.version.split()[0])" + $pyversion = python -c "import sys; print(sys.version.split()[0])" Write-Host "Python Version: $pyversion" $target = "C:\\hostedtoolcache\\windows\\Python\\$pyversion\\$(PYTHON_ARCH)\\lib\\openblas$env:OPENBLAS_SUFFIX.a" Write-Host "target path: $target" @@ -53,4 +53,4 @@ steps: inputs: testResultsFiles: '**/test-*.xml' failTaskOnFailedTests: true - testRunTitle: 'Publish test results for Python $(PYTHON_VERSION) $(BITS)-bit $(TEST_MODE) Windows' \ No newline at end of file + testRunTitle: 'Publish test results for Python $(PYTHON_VERSION) $(BITS)-bit $(TEST_MODE) Windows' diff --git a/benchmarks/benchmarks/__init__.py b/benchmarks/benchmarks/__init__.py index e8a859ff4784..e4193cf0582f 100644 --- a/benchmarks/benchmarks/__init__.py +++ b/benchmarks/benchmarks/__init__.py @@ -1,3 +1 @@ -from __future__ import absolute_import, division, print_function - from . import common diff --git a/benchmarks/benchmarks/bench_app.py b/benchmarks/benchmarks/bench_app.py index ccf6e4c4af85..2a649f39bcf0 100644 --- a/benchmarks/benchmarks/bench_app.py +++ b/benchmarks/benchmarks/bench_app.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import, division, print_function - from .common import Benchmark import numpy as np diff --git a/benchmarks/benchmarks/bench_avx.py b/benchmarks/benchmarks/bench_avx.py index f7b524e43ba0..023696b90d3e 100644 --- a/benchmarks/benchmarks/bench_avx.py +++ b/benchmarks/benchmarks/bench_avx.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import, division, print_function - from .common import Benchmark import numpy as np @@ -31,4 +29,3 @@ def setup(self, ufuncname, stride, dtype): def time_ufunc(self, ufuncname, stride, dtype): self.f(self.arr[::stride]) - diff --git a/benchmarks/benchmarks/bench_core.py b/benchmarks/benchmarks/bench_core.py index f7ce61b8f9ca..94d3ad503d88 100644 --- a/benchmarks/benchmarks/bench_core.py +++ b/benchmarks/benchmarks/bench_core.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import, division, print_function - from .common import Benchmark import numpy as np diff --git a/benchmarks/benchmarks/bench_function_base.py b/benchmarks/benchmarks/bench_function_base.py index 2170c4fc4cd5..3b4647773e8f 100644 --- a/benchmarks/benchmarks/bench_function_base.py +++ b/benchmarks/benchmarks/bench_function_base.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import, division, print_function - from .common import Benchmark import numpy as np diff --git a/benchmarks/benchmarks/bench_import.py b/benchmarks/benchmarks/bench_import.py index 83edecafebea..4b6ecbc7bbb1 100644 --- a/benchmarks/benchmarks/bench_import.py +++ b/benchmarks/benchmarks/bench_import.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import, division, print_function - from subprocess import call from sys import executable from timeit import default_timer diff --git a/benchmarks/benchmarks/bench_indexing.py b/benchmarks/benchmarks/bench_indexing.py index a62a2050e283..bb7596d0ad01 100644 --- a/benchmarks/benchmarks/bench_indexing.py +++ b/benchmarks/benchmarks/bench_indexing.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import, division, print_function - from .common import Benchmark, get_squares_, get_indexes_, get_indexes_rand_ from os.path import join as pjoin diff --git a/benchmarks/benchmarks/bench_io.py b/benchmarks/benchmarks/bench_io.py index 439cd422f5fc..d5ce9a271cba 100644 --- a/benchmarks/benchmarks/bench_io.py +++ b/benchmarks/benchmarks/bench_io.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import, division, print_function - from .common import Benchmark, get_squares import numpy as np diff --git a/benchmarks/benchmarks/bench_lib.py b/benchmarks/benchmarks/bench_lib.py index f65a96dadd3a..c22ceaa5e42f 100644 --- a/benchmarks/benchmarks/bench_lib.py +++ b/benchmarks/benchmarks/bench_lib.py @@ -1,8 +1,6 @@ """Benchmarks for `numpy.lib`.""" -from __future__ import absolute_import, division, print_function - from .common import Benchmark import numpy as np diff --git a/benchmarks/benchmarks/bench_linalg.py b/benchmarks/benchmarks/bench_linalg.py index 5c44162a23cf..3abbe36705c6 100644 --- a/benchmarks/benchmarks/bench_linalg.py +++ b/benchmarks/benchmarks/bench_linalg.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import, division, print_function - from .common import Benchmark, get_squares_, get_indexes_rand, TYPES1 import numpy as np diff --git a/benchmarks/benchmarks/bench_ma.py b/benchmarks/benchmarks/bench_ma.py index aff78df0a5aa..b214c0b86519 100644 --- a/benchmarks/benchmarks/bench_ma.py +++ b/benchmarks/benchmarks/bench_ma.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import, division, print_function - from .common import Benchmark import numpy as np diff --git a/benchmarks/benchmarks/bench_overrides.py b/benchmarks/benchmarks/bench_overrides.py index 58572d07d050..f03120efa5fe 100644 --- a/benchmarks/benchmarks/bench_overrides.py +++ b/benchmarks/benchmarks/bench_overrides.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import, division, print_function - from .common import Benchmark try: diff --git a/benchmarks/benchmarks/bench_random.py b/benchmarks/benchmarks/bench_random.py index c52b463e5797..9a5125876d08 100644 --- a/benchmarks/benchmarks/bench_random.py +++ b/benchmarks/benchmarks/bench_random.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import, division, print_function - from .common import Benchmark import numpy as np diff --git a/benchmarks/benchmarks/bench_records.py b/benchmarks/benchmarks/bench_records.py index 41a6dd775bb4..92e0fca1697b 100644 --- a/benchmarks/benchmarks/bench_records.py +++ b/benchmarks/benchmarks/bench_records.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import, division, print_function import os from .common import Benchmark diff --git a/benchmarks/benchmarks/bench_reduce.py b/benchmarks/benchmarks/bench_reduce.py index 0043d5357575..76c573a51963 100644 --- a/benchmarks/benchmarks/bench_reduce.py +++ b/benchmarks/benchmarks/bench_reduce.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import, division, print_function - from .common import Benchmark, TYPES1, get_squares import numpy as np diff --git a/benchmarks/benchmarks/bench_shape_base.py b/benchmarks/benchmarks/bench_shape_base.py index 187b923cd27a..0c7dc4e728ec 100644 --- a/benchmarks/benchmarks/bench_shape_base.py +++ b/benchmarks/benchmarks/bench_shape_base.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import, division, print_function - from .common import Benchmark import numpy as np diff --git a/benchmarks/benchmarks/bench_ufunc.py b/benchmarks/benchmarks/bench_ufunc.py index 62e70782d1f7..73159bd97903 100644 --- a/benchmarks/benchmarks/bench_ufunc.py +++ b/benchmarks/benchmarks/bench_ufunc.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import, division, print_function - from .common import Benchmark, get_squares_ import numpy as np diff --git a/benchmarks/benchmarks/common.py b/benchmarks/benchmarks/common.py index 18a09fd40551..c6037dea9fb8 100644 --- a/benchmarks/benchmarks/common.py +++ b/benchmarks/benchmarks/common.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import, division, print_function - import numpy import random diff --git a/doc/DISTUTILS.rst.txt b/doc/DISTUTILS.rst.txt index bcef82500ba4..677398baa5d5 100644 --- a/doc/DISTUTILS.rst.txt +++ b/doc/DISTUTILS.rst.txt @@ -577,9 +577,6 @@ The header of a typical SciPy ``__init__.py`` is:: Package docstring, typically with a brief description and function listing. """ - # py3k related imports - from __future__ import division, print_function, absolute_import - # import functions into module namespace from .subpackage import * ... diff --git a/doc/cdoc/numpyfilter.py b/doc/cdoc/numpyfilter.py index 0ec50697e119..65c801206184 100755 --- a/doc/cdoc/numpyfilter.py +++ b/doc/cdoc/numpyfilter.py @@ -6,8 +6,6 @@ Also, add Doxygen /** and /**< syntax automatically where appropriate. """ -from __future__ import division, absolute_import, print_function - import sys import re import os diff --git a/doc/example.py b/doc/example.py index 8a5f9948f3cb..5e3d79807d8c 100644 --- a/doc/example.py +++ b/doc/example.py @@ -8,8 +8,6 @@ a line by itself, preferably preceded by a blank line. """ -from __future__ import division, absolute_import, print_function - import os # standard library imports first # Do NOT import using *, e.g. from numpy import * diff --git a/doc/postprocess.py b/doc/postprocess.py index 2e50c115edbe..b6d0674371da 100755 --- a/doc/postprocess.py +++ b/doc/postprocess.py @@ -6,8 +6,6 @@ MODE is either 'html' or 'tex'. """ -from __future__ import division, absolute_import, print_function - import re import optparse import io diff --git a/doc/source/conf.py b/doc/source/conf.py index 09770535b698..7e3a145f5a61 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -1,6 +1,4 @@ # -*- coding: utf-8 -*- -from __future__ import division, absolute_import, print_function - import sys, os, re # Minimum version, enforced by sphinx diff --git a/doc/source/f2py/setup_example.py b/doc/source/f2py/setup_example.py index 54af7729988e..479acc004d60 100644 --- a/doc/source/f2py/setup_example.py +++ b/doc/source/f2py/setup_example.py @@ -1,5 +1,3 @@ -from __future__ import division, absolute_import, print_function - from numpy.distutils.core import Extension ext1 = Extension(name = 'scalar', diff --git a/doc/source/reference/arrays.ndarray.rst b/doc/source/reference/arrays.ndarray.rst index 831d211bc516..47692c8b4291 100644 --- a/doc/source/reference/arrays.ndarray.rst +++ b/doc/source/reference/arrays.ndarray.rst @@ -512,10 +512,6 @@ Arithmetic: - Any third argument to :func:`pow()` is silently ignored, as the underlying :func:`ufunc ` takes only two arguments. - - The three division operators are all defined; :obj:`div` is active - by default, :obj:`truediv` is active when - :obj:`__future__` division is in effect. - - Because :class:`ndarray` is a built-in type (written in C), the ``__r{op}__`` special methods are not directly defined. diff --git a/doc/summarize.py b/doc/summarize.py index cfce2713edf6..9b02a408cd12 100755 --- a/doc/summarize.py +++ b/doc/summarize.py @@ -5,8 +5,6 @@ Show a summary about which NumPy functions are documented and which are not. """ -from __future__ import division, absolute_import, print_function - import os, glob, re, sys, inspect, optparse try: # Accessing collections abstract classes from collections diff --git a/numpy/__init__.py b/numpy/__init__.py index 349914b2f3a7..73e979a1841d 100644 --- a/numpy/__init__.py +++ b/numpy/__init__.py @@ -104,8 +104,6 @@ Exceptions to this rule are documented. """ -from __future__ import division, absolute_import, print_function - import sys import warnings diff --git a/numpy/_build_utils/__init__.py b/numpy/_build_utils/__init__.py index 1d0f69b67d8f..e69de29bb2d1 100644 --- a/numpy/_build_utils/__init__.py +++ b/numpy/_build_utils/__init__.py @@ -1 +0,0 @@ -from __future__ import division, absolute_import, print_function diff --git a/numpy/_build_utils/apple_accelerate.py b/numpy/_build_utils/apple_accelerate.py index 36dd7584a6e4..b26aa12ad978 100644 --- a/numpy/_build_utils/apple_accelerate.py +++ b/numpy/_build_utils/apple_accelerate.py @@ -1,5 +1,3 @@ -from __future__ import division, absolute_import, print_function - import os import sys import re diff --git a/numpy/_globals.py b/numpy/_globals.py index f5c0761b5837..6361d94b0a16 100644 --- a/numpy/_globals.py +++ b/numpy/_globals.py @@ -15,8 +15,6 @@ def foo(arg=np._NoValue): motivated this module. """ -from __future__ import division, absolute_import, print_function - __ALL__ = [ 'ModuleDeprecationWarning', 'VisibleDeprecationWarning', '_NoValue' ] diff --git a/numpy/_pytesttester.py b/numpy/_pytesttester.py index 6462fc5e60f1..579d467c3184 100644 --- a/numpy/_pytesttester.py +++ b/numpy/_pytesttester.py @@ -27,8 +27,6 @@ simplify circular import issues. For the same reason, it contains no numpy imports at module scope, instead importing numpy within function calls. """ -from __future__ import division, absolute_import, print_function - import sys import os diff --git a/numpy/compat/__init__.py b/numpy/compat/__init__.py index 5b371f5c064b..afee621b8726 100644 --- a/numpy/compat/__init__.py +++ b/numpy/compat/__init__.py @@ -8,8 +8,6 @@ * we may only need a small subset of the copied library/module """ -from __future__ import division, absolute_import, print_function - from . import _inspect from . import py3k from ._inspect import getargspec, formatargspec diff --git a/numpy/compat/_inspect.py b/numpy/compat/_inspect.py index 439d0d2c2ff7..9a874a71dd0a 100644 --- a/numpy/compat/_inspect.py +++ b/numpy/compat/_inspect.py @@ -5,8 +5,6 @@ no overhead. """ -from __future__ import division, absolute_import, print_function - import types __all__ = ['getargspec', 'formatargspec'] diff --git a/numpy/compat/setup.py b/numpy/compat/setup.py index 882857428cdf..afa511673abb 100644 --- a/numpy/compat/setup.py +++ b/numpy/compat/setup.py @@ -1,5 +1,3 @@ -from __future__ import division, print_function - def configuration(parent_package='',top_path=None): from numpy.distutils.misc_util import Configuration diff --git a/numpy/compat/tests/test_compat.py b/numpy/compat/tests/test_compat.py index 1543aafaf540..2b8acbaa0662 100644 --- a/numpy/compat/tests/test_compat.py +++ b/numpy/compat/tests/test_compat.py @@ -1,5 +1,3 @@ -from __future__ import division, absolute_import, print_function - from os.path import join from numpy.compat import isfileobj diff --git a/numpy/conftest.py b/numpy/conftest.py index 1baf4adda507..a843f725fc8b 100644 --- a/numpy/conftest.py +++ b/numpy/conftest.py @@ -1,8 +1,6 @@ """ Pytest configuration and fixtures for the Numpy test suite. """ -from __future__ import division, absolute_import, print_function - import os import pytest diff --git a/numpy/core/__init__.py b/numpy/core/__init__.py index c3b3f0392702..815c61924668 100644 --- a/numpy/core/__init__.py +++ b/numpy/core/__init__.py @@ -6,8 +6,6 @@ """ -from __future__ import division, absolute_import, print_function - from numpy.version import version as __version__ import os diff --git a/numpy/core/_add_newdocs.py b/numpy/core/_add_newdocs.py index d552348d0faa..36fc9d7d6a50 100644 --- a/numpy/core/_add_newdocs.py +++ b/numpy/core/_add_newdocs.py @@ -8,8 +8,6 @@ core/fromnumeric.py, core/defmatrix.py up-to-date. """ -from __future__ import division, absolute_import, print_function - import sys from numpy.core import numerictypes as _numerictypes diff --git a/numpy/core/_asarray.py b/numpy/core/_asarray.py index 0ad4161f4e75..df569f22d97a 100644 --- a/numpy/core/_asarray.py +++ b/numpy/core/_asarray.py @@ -3,8 +3,6 @@ `require` fits this category despite its name not matching this pattern. """ -from __future__ import division, absolute_import, print_function - from .overrides import set_module from .multiarray import array diff --git a/numpy/core/_dtype.py b/numpy/core/_dtype.py index df1ff180eb46..fa39dfcd48a8 100644 --- a/numpy/core/_dtype.py +++ b/numpy/core/_dtype.py @@ -3,8 +3,6 @@ String handling is much easier to do correctly in python. """ -from __future__ import division, absolute_import, print_function - import sys import numpy as np diff --git a/numpy/core/_internal.py b/numpy/core/_internal.py index 05e401e0bbef..d7a46c2d0b5c 100644 --- a/numpy/core/_internal.py +++ b/numpy/core/_internal.py @@ -4,8 +4,6 @@ Some things are more easily handled Python. """ -from __future__ import division, absolute_import, print_function - import re import sys import platform diff --git a/numpy/core/_methods.py b/numpy/core/_methods.py index 269e509b860e..694523b20a97 100644 --- a/numpy/core/_methods.py +++ b/numpy/core/_methods.py @@ -3,8 +3,6 @@ and the Python code for the NumPy-namespace function """ -from __future__ import division, absolute_import, print_function - import warnings from numpy.core import multiarray as mu diff --git a/numpy/core/_ufunc_config.py b/numpy/core/_ufunc_config.py index c3951cc098b5..39ccd3aca5d3 100644 --- a/numpy/core/_ufunc_config.py +++ b/numpy/core/_ufunc_config.py @@ -3,8 +3,6 @@ This provides helpers which wrap `umath.geterrobj` and `umath.seterrobj` """ -from __future__ import division, absolute_import, print_function - try: # Accessing collections abstract classes from collections # has been deprecated since Python 3.3 @@ -431,8 +429,6 @@ class errstate(contextlib.ContextDecorator): OrderedDict([('divide', 'ignore'), ('invalid', 'ignore'), ('over', 'ignore'), ('under', 'ignore')]) """ - # Note that we don't want to run the above doctests because they will fail - # without a from __future__ import with_statement def __init__(self, **kwargs): self.call = kwargs.pop('call', _Unspecified) diff --git a/numpy/core/arrayprint.py b/numpy/core/arrayprint.py index 4010180150c4..696f64c6a4a2 100644 --- a/numpy/core/arrayprint.py +++ b/numpy/core/arrayprint.py @@ -3,8 +3,6 @@ $Id: arrayprint.py,v 1.9 2005/09/13 13:58:44 teoliphant Exp $ """ -from __future__ import division, absolute_import, print_function - __all__ = ["array2string", "array_str", "array_repr", "set_string_function", "set_printoptions", "get_printoptions", "printoptions", "format_float_positional", "format_float_scientific"] diff --git a/numpy/core/code_generators/__init__.py b/numpy/core/code_generators/__init__.py index 1d0f69b67d8f..e69de29bb2d1 100644 --- a/numpy/core/code_generators/__init__.py +++ b/numpy/core/code_generators/__init__.py @@ -1 +0,0 @@ -from __future__ import division, absolute_import, print_function diff --git a/numpy/core/code_generators/genapi.py b/numpy/core/code_generators/genapi.py index 22afa0320a6d..95939e7ecca2 100644 --- a/numpy/core/code_generators/genapi.py +++ b/numpy/core/code_generators/genapi.py @@ -6,8 +6,6 @@ specified. """ -from __future__ import division, absolute_import, print_function - from numpy.distutils.conv_template import process_file as process_c_file import sys, os, re diff --git a/numpy/core/code_generators/generate_numpy_api.py b/numpy/core/code_generators/generate_numpy_api.py index 5e04fb86dd4f..59abeffcb012 100644 --- a/numpy/core/code_generators/generate_numpy_api.py +++ b/numpy/core/code_generators/generate_numpy_api.py @@ -1,5 +1,3 @@ -from __future__ import division, print_function - import os import genapi diff --git a/numpy/core/code_generators/generate_ufunc_api.py b/numpy/core/code_generators/generate_ufunc_api.py index 1b0143e88be5..60a71849a782 100644 --- a/numpy/core/code_generators/generate_ufunc_api.py +++ b/numpy/core/code_generators/generate_ufunc_api.py @@ -1,5 +1,3 @@ -from __future__ import division, print_function - import os import genapi diff --git a/numpy/core/code_generators/generate_umath.py b/numpy/core/code_generators/generate_umath.py index 6d76f7ca21c4..99e180477c11 100644 --- a/numpy/core/code_generators/generate_umath.py +++ b/numpy/core/code_generators/generate_umath.py @@ -1,5 +1,3 @@ -from __future__ import division, print_function - import os import re import struct diff --git a/numpy/core/code_generators/numpy_api.py b/numpy/core/code_generators/numpy_api.py index a71c236fdde4..916fb537e863 100644 --- a/numpy/core/code_generators/numpy_api.py +++ b/numpy/core/code_generators/numpy_api.py @@ -13,8 +13,6 @@ exception, so it should hopefully not get unnoticed). """ -from __future__ import division, absolute_import, print_function - from code_generators.genapi import StealRef, NonNull # index, type diff --git a/numpy/core/code_generators/ufunc_docstrings.py b/numpy/core/code_generators/ufunc_docstrings.py index 9560eb31b38a..33ad1502d787 100644 --- a/numpy/core/code_generators/ufunc_docstrings.py +++ b/numpy/core/code_generators/ufunc_docstrings.py @@ -9,7 +9,6 @@ at compile time. """ -from __future__ import division, absolute_import, print_function import textwrap docdict = {} @@ -3826,12 +3825,7 @@ def add_newdoc(place, name, doc): Notes ----- - The floor division operator ``//`` was added in Python 2.2 making - ``//`` and ``/`` equivalent operators. The default floor division - operation of ``/`` can be replaced by true division with ``from - __future__ import division``. - - In Python 3.0, ``//`` is the floor division operator and ``/`` the + In Python, ``//`` is the floor division operator and ``/`` the true division operator. The ``true_divide(x1, x2)`` function is equivalent to true division in Python. @@ -3844,7 +3838,6 @@ def add_newdoc(place, name, doc): >>> x//4 array([0, 0, 0, 0, 1]) - >>> from __future__ import division >>> x/4 array([ 0. , 0.25, 0.5 , 0.75, 1. ]) >>> x//4 diff --git a/numpy/core/cversions.py b/numpy/core/cversions.py index 7995dd9931e7..00159c3a8031 100644 --- a/numpy/core/cversions.py +++ b/numpy/core/cversions.py @@ -3,8 +3,6 @@ The API has is defined by numpy_api_order and ufunc_api_order. """ -from __future__ import division, absolute_import, print_function - from os.path import dirname from code_generators.genapi import fullapi_hash diff --git a/numpy/core/defchararray.py b/numpy/core/defchararray.py index 168fd8c790ae..ff1474d9da5f 100644 --- a/numpy/core/defchararray.py +++ b/numpy/core/defchararray.py @@ -15,8 +15,6 @@ The preferred alias for `defchararray` is `numpy.char`. """ -from __future__ import division, absolute_import, print_function - import functools import sys from .numerictypes import string_, unicode_, integer, object_, bool_, character diff --git a/numpy/core/einsumfunc.py b/numpy/core/einsumfunc.py index 3412c3fd5a7e..8ae14ce30fae 100644 --- a/numpy/core/einsumfunc.py +++ b/numpy/core/einsumfunc.py @@ -2,8 +2,6 @@ Implementation of optimized einsum. """ -from __future__ import division, absolute_import, print_function - import itertools from numpy.compat import basestring diff --git a/numpy/core/fromnumeric.py b/numpy/core/fromnumeric.py index f09f2a465d0e..51b1437623e7 100644 --- a/numpy/core/fromnumeric.py +++ b/numpy/core/fromnumeric.py @@ -1,8 +1,6 @@ """Module containing non-deprecated functions borrowed from Numeric. """ -from __future__ import division, absolute_import, print_function - import functools import types import warnings diff --git a/numpy/core/function_base.py b/numpy/core/function_base.py index 538ac8b842a6..8f92a4f71fce 100644 --- a/numpy/core/function_base.py +++ b/numpy/core/function_base.py @@ -1,5 +1,3 @@ -from __future__ import division, absolute_import, print_function - import functools import warnings import operator diff --git a/numpy/core/getlimits.py b/numpy/core/getlimits.py index 31fa6b9bfafc..fda0933a3759 100644 --- a/numpy/core/getlimits.py +++ b/numpy/core/getlimits.py @@ -1,8 +1,6 @@ """Machine limits for Float32 and Float64 and (long double) if available... """ -from __future__ import division, absolute_import, print_function - __all__ = ['finfo', 'iinfo'] import warnings diff --git a/numpy/core/machar.py b/numpy/core/machar.py index 202580bdb064..202cbf62397a 100644 --- a/numpy/core/machar.py +++ b/numpy/core/machar.py @@ -5,8 +5,6 @@ Author: Pearu Peterson, September 2003 """ -from __future__ import division, absolute_import, print_function - __all__ = ['MachAr'] from numpy.core.fromnumeric import any diff --git a/numpy/core/memmap.py b/numpy/core/memmap.py index 062645551ed5..ad0d7ad79fb7 100644 --- a/numpy/core/memmap.py +++ b/numpy/core/memmap.py @@ -1,5 +1,3 @@ -from __future__ import division, absolute_import, print_function - import numpy as np from .numeric import uint8, ndarray, dtype from numpy.compat import ( diff --git a/numpy/core/numeric.py b/numpy/core/numeric.py index 1e011e2e73df..af289ca3df1f 100644 --- a/numpy/core/numeric.py +++ b/numpy/core/numeric.py @@ -1,5 +1,3 @@ -from __future__ import division, absolute_import, print_function - import functools import itertools import operator diff --git a/numpy/core/numerictypes.py b/numpy/core/numerictypes.py index 761c7087caef..c63ea08c79af 100644 --- a/numpy/core/numerictypes.py +++ b/numpy/core/numerictypes.py @@ -79,8 +79,6 @@ \\-> object_ (not used much) (kind=O) """ -from __future__ import division, absolute_import, print_function - import types as _types import sys import numbers diff --git a/numpy/core/records.py b/numpy/core/records.py index a1cad9075629..b867d84d99a0 100644 --- a/numpy/core/records.py +++ b/numpy/core/records.py @@ -33,8 +33,6 @@ array([2., 2.]) """ -from __future__ import division, absolute_import, print_function - import sys import os import warnings diff --git a/numpy/core/setup.py b/numpy/core/setup.py index 974ec4628c72..6e5d63aae499 100644 --- a/numpy/core/setup.py +++ b/numpy/core/setup.py @@ -1,5 +1,3 @@ -from __future__ import division, print_function - import os import sys import pickle diff --git a/numpy/core/setup_common.py b/numpy/core/setup_common.py index 6356f08ba307..a947f7a3dfde 100644 --- a/numpy/core/setup_common.py +++ b/numpy/core/setup_common.py @@ -1,5 +1,3 @@ -from __future__ import division, absolute_import, print_function - # Code common to build tools import sys import warnings diff --git a/numpy/core/shape_base.py b/numpy/core/shape_base.py index 31b1c20b974c..d2f26149b02e 100644 --- a/numpy/core/shape_base.py +++ b/numpy/core/shape_base.py @@ -1,5 +1,3 @@ -from __future__ import division, absolute_import, print_function - __all__ = ['atleast_1d', 'atleast_2d', 'atleast_3d', 'block', 'hstack', 'stack', 'vstack'] diff --git a/numpy/core/tests/_locales.py b/numpy/core/tests/_locales.py index 52e4ff36d5ed..4739e6c10292 100644 --- a/numpy/core/tests/_locales.py +++ b/numpy/core/tests/_locales.py @@ -1,8 +1,6 @@ """Provide class for testing in French locale """ -from __future__ import division, absolute_import, print_function - import sys import locale diff --git a/numpy/core/tests/test_abc.py b/numpy/core/tests/test_abc.py index d9c61b0c6115..4c5a6e42c5de 100644 --- a/numpy/core/tests/test_abc.py +++ b/numpy/core/tests/test_abc.py @@ -1,5 +1,3 @@ -from __future__ import division, absolute_import, print_function - from numpy.testing import assert_ import numbers diff --git a/numpy/core/tests/test_api.py b/numpy/core/tests/test_api.py index 89fc2b0b9092..3f0a59eec1b7 100644 --- a/numpy/core/tests/test_api.py +++ b/numpy/core/tests/test_api.py @@ -1,5 +1,3 @@ -from __future__ import division, absolute_import, print_function - import sys import numpy as np diff --git a/numpy/core/tests/test_arrayprint.py b/numpy/core/tests/test_arrayprint.py index 702e68e769f0..d532c96f145a 100644 --- a/numpy/core/tests/test_arrayprint.py +++ b/numpy/core/tests/test_arrayprint.py @@ -1,6 +1,4 @@ # -*- coding: utf-8 -*- -from __future__ import division, absolute_import, print_function - import sys import gc import pytest diff --git a/numpy/core/tests/test_datetime.py b/numpy/core/tests/test_datetime.py index d38444ef7ea1..4fb0bb9164f8 100644 --- a/numpy/core/tests/test_datetime.py +++ b/numpy/core/tests/test_datetime.py @@ -1,5 +1,3 @@ -from __future__ import division, absolute_import, print_function - import numpy import numpy as np diff --git a/numpy/core/tests/test_defchararray.py b/numpy/core/tests/test_defchararray.py index 7b0e6f8a4bee..2bfd568b8939 100644 --- a/numpy/core/tests/test_defchararray.py +++ b/numpy/core/tests/test_defchararray.py @@ -1,5 +1,3 @@ -from __future__ import division, absolute_import, print_function - import sys import numpy as np diff --git a/numpy/core/tests/test_deprecations.py b/numpy/core/tests/test_deprecations.py index 363ff26db320..050d3b0e260b 100644 --- a/numpy/core/tests/test_deprecations.py +++ b/numpy/core/tests/test_deprecations.py @@ -3,8 +3,6 @@ to document how deprecations should eventually be turned into errors. """ -from __future__ import division, absolute_import, print_function - import datetime import sys import operator diff --git a/numpy/core/tests/test_dtype.py b/numpy/core/tests/test_dtype.py index b347a9de7cf8..9c279963d765 100644 --- a/numpy/core/tests/test_dtype.py +++ b/numpy/core/tests/test_dtype.py @@ -1,5 +1,3 @@ -from __future__ import division, absolute_import, print_function - import sys import operator import pytest diff --git a/numpy/core/tests/test_einsum.py b/numpy/core/tests/test_einsum.py index 1b5b4cb26244..3d19edbfc4d6 100644 --- a/numpy/core/tests/test_einsum.py +++ b/numpy/core/tests/test_einsum.py @@ -1,5 +1,3 @@ -from __future__ import division, absolute_import, print_function - import itertools import numpy as np diff --git a/numpy/core/tests/test_errstate.py b/numpy/core/tests/test_errstate.py index 0008c4cc8023..9e0993290d74 100644 --- a/numpy/core/tests/test_errstate.py +++ b/numpy/core/tests/test_errstate.py @@ -1,5 +1,3 @@ -from __future__ import division, absolute_import, print_function - import platform import pytest diff --git a/numpy/core/tests/test_extint128.py b/numpy/core/tests/test_extint128.py index 7c454a603b60..3b64915f36a3 100644 --- a/numpy/core/tests/test_extint128.py +++ b/numpy/core/tests/test_extint128.py @@ -1,5 +1,3 @@ -from __future__ import division, absolute_import, print_function - import itertools import contextlib import operator diff --git a/numpy/core/tests/test_function_base.py b/numpy/core/tests/test_function_base.py index c8a7cb6ce87d..8d9ef0520ed8 100644 --- a/numpy/core/tests/test_function_base.py +++ b/numpy/core/tests/test_function_base.py @@ -1,5 +1,3 @@ -from __future__ import division, absolute_import, print_function - from numpy import ( logspace, linspace, geomspace, dtype, array, sctypes, arange, isnan, ndarray, sqrt, nextafter, stack diff --git a/numpy/core/tests/test_getlimits.py b/numpy/core/tests/test_getlimits.py index 2f6648183650..598a481ed30a 100644 --- a/numpy/core/tests/test_getlimits.py +++ b/numpy/core/tests/test_getlimits.py @@ -1,8 +1,6 @@ """ Test functions for limits module. """ -from __future__ import division, absolute_import, print_function - import numpy as np from numpy.core import finfo, iinfo from numpy import half, single, double, longdouble diff --git a/numpy/core/tests/test_half.py b/numpy/core/tests/test_half.py index 1e1e6d7d9ab1..7a12698e441a 100644 --- a/numpy/core/tests/test_half.py +++ b/numpy/core/tests/test_half.py @@ -1,5 +1,3 @@ -from __future__ import division, absolute_import, print_function - import platform import pytest diff --git a/numpy/core/tests/test_indexerrors.py b/numpy/core/tests/test_indexerrors.py index 63b43c473c8a..3fd76b91b6aa 100644 --- a/numpy/core/tests/test_indexerrors.py +++ b/numpy/core/tests/test_indexerrors.py @@ -1,5 +1,3 @@ -from __future__ import division, absolute_import, print_function - import numpy as np from numpy.testing import assert_raises diff --git a/numpy/core/tests/test_indexing.py b/numpy/core/tests/test_indexing.py index 70a5a246f39b..7f2b1dff4e72 100644 --- a/numpy/core/tests/test_indexing.py +++ b/numpy/core/tests/test_indexing.py @@ -1,5 +1,3 @@ -from __future__ import division, absolute_import, print_function - import sys import warnings import functools diff --git a/numpy/core/tests/test_item_selection.py b/numpy/core/tests/test_item_selection.py index 9bd24686629b..b28b2d5dacd7 100644 --- a/numpy/core/tests/test_item_selection.py +++ b/numpy/core/tests/test_item_selection.py @@ -1,5 +1,3 @@ -from __future__ import division, absolute_import, print_function - import sys import numpy as np diff --git a/numpy/core/tests/test_longdouble.py b/numpy/core/tests/test_longdouble.py index 2b6e1c5a290e..b1db252c3000 100644 --- a/numpy/core/tests/test_longdouble.py +++ b/numpy/core/tests/test_longdouble.py @@ -1,5 +1,3 @@ -from __future__ import division, absolute_import, print_function - import warnings import pytest diff --git a/numpy/core/tests/test_machar.py b/numpy/core/tests/test_machar.py index 64a0ffa3db68..43d5871a956b 100644 --- a/numpy/core/tests/test_machar.py +++ b/numpy/core/tests/test_machar.py @@ -3,8 +3,6 @@ rid of both MachAr and this test at some point. """ -from __future__ import division, absolute_import, print_function - from numpy.core.machar import MachAr import numpy.core.numerictypes as ntypes from numpy import errstate, array diff --git a/numpy/core/tests/test_mem_overlap.py b/numpy/core/tests/test_mem_overlap.py index 3c8e0e7220d2..876ac2455e5d 100644 --- a/numpy/core/tests/test_mem_overlap.py +++ b/numpy/core/tests/test_mem_overlap.py @@ -1,5 +1,3 @@ -from __future__ import division, absolute_import, print_function - import sys import itertools import pytest diff --git a/numpy/core/tests/test_memmap.py b/numpy/core/tests/test_memmap.py index d2ae564b24da..b8d0651ca0b1 100644 --- a/numpy/core/tests/test_memmap.py +++ b/numpy/core/tests/test_memmap.py @@ -1,5 +1,3 @@ -from __future__ import division, absolute_import, print_function - import sys import os import shutil diff --git a/numpy/core/tests/test_multiarray.py b/numpy/core/tests/test_multiarray.py index d801dbf917ce..64798183583a 100644 --- a/numpy/core/tests/test_multiarray.py +++ b/numpy/core/tests/test_multiarray.py @@ -1,5 +1,3 @@ -from __future__ import division, absolute_import, print_function - try: # Accessing collections abstract classes from collections # has been deprecated since Python 3.3 diff --git a/numpy/core/tests/test_nditer.py b/numpy/core/tests/test_nditer.py index daec9ce6df67..2670768516d6 100644 --- a/numpy/core/tests/test_nditer.py +++ b/numpy/core/tests/test_nditer.py @@ -1,5 +1,3 @@ -from __future__ import division, absolute_import, print_function - import sys import pytest diff --git a/numpy/core/tests/test_numeric.py b/numpy/core/tests/test_numeric.py index ffebdf64870c..8ad460a09b0f 100644 --- a/numpy/core/tests/test_numeric.py +++ b/numpy/core/tests/test_numeric.py @@ -1,5 +1,3 @@ -from __future__ import division, absolute_import, print_function - import sys import warnings import itertools diff --git a/numpy/core/tests/test_numerictypes.py b/numpy/core/tests/test_numerictypes.py index 387740e35707..439aa3ff9086 100644 --- a/numpy/core/tests/test_numerictypes.py +++ b/numpy/core/tests/test_numerictypes.py @@ -1,5 +1,3 @@ -from __future__ import division, absolute_import, print_function - import sys import itertools diff --git a/numpy/core/tests/test_overrides.py b/numpy/core/tests/test_overrides.py index 63b0e4539e9e..8a1cccb74847 100644 --- a/numpy/core/tests/test_overrides.py +++ b/numpy/core/tests/test_overrides.py @@ -1,5 +1,3 @@ -from __future__ import division, absolute_import, print_function - import inspect import sys from unittest import mock diff --git a/numpy/core/tests/test_print.py b/numpy/core/tests/test_print.py index c5c091e13ac8..36d652a41a47 100644 --- a/numpy/core/tests/test_print.py +++ b/numpy/core/tests/test_print.py @@ -1,5 +1,3 @@ -from __future__ import division, absolute_import, print_function - import sys import pytest diff --git a/numpy/core/tests/test_records.py b/numpy/core/tests/test_records.py index 0f88f99e0f68..e2c8d12f0a4e 100644 --- a/numpy/core/tests/test_records.py +++ b/numpy/core/tests/test_records.py @@ -1,5 +1,3 @@ -from __future__ import division, absolute_import, print_function - import sys try: # Accessing collections abstract classes from collections diff --git a/numpy/core/tests/test_regression.py b/numpy/core/tests/test_regression.py index f2f9c1457ed9..d1116960bed8 100644 --- a/numpy/core/tests/test_regression.py +++ b/numpy/core/tests/test_regression.py @@ -1,5 +1,3 @@ -from __future__ import division, absolute_import, print_function - import copy import sys import gc diff --git a/numpy/core/tests/test_scalar_ctors.py b/numpy/core/tests/test_scalar_ctors.py index b21bc9dad07d..dbe57de023c3 100644 --- a/numpy/core/tests/test_scalar_ctors.py +++ b/numpy/core/tests/test_scalar_ctors.py @@ -1,8 +1,6 @@ """ Test the scalar constructors, which also do type-coercion """ -from __future__ import division, absolute_import, print_function - import sys import platform import pytest diff --git a/numpy/core/tests/test_scalar_methods.py b/numpy/core/tests/test_scalar_methods.py index 93434dd1bf64..ab16b4e67684 100644 --- a/numpy/core/tests/test_scalar_methods.py +++ b/numpy/core/tests/test_scalar_methods.py @@ -1,8 +1,6 @@ """ Test the scalar constructors, which also do type-coercion """ -from __future__ import division, absolute_import, print_function - import os import fractions import platform diff --git a/numpy/core/tests/test_scalarinherit.py b/numpy/core/tests/test_scalarinherit.py index 6a5c4fde9da5..a2e34fdee924 100644 --- a/numpy/core/tests/test_scalarinherit.py +++ b/numpy/core/tests/test_scalarinherit.py @@ -2,8 +2,6 @@ """ Test printing of scalar types. """ -from __future__ import division, absolute_import, print_function - import numpy as np from numpy.testing import assert_ diff --git a/numpy/core/tests/test_scalarmath.py b/numpy/core/tests/test_scalarmath.py index c84380cd9ca0..25a8b65269e9 100644 --- a/numpy/core/tests/test_scalarmath.py +++ b/numpy/core/tests/test_scalarmath.py @@ -1,5 +1,3 @@ -from __future__ import division, absolute_import, print_function - import sys import warnings import itertools diff --git a/numpy/core/tests/test_scalarprint.py b/numpy/core/tests/test_scalarprint.py index 86b0ca1990c3..b12fdb249f6b 100644 --- a/numpy/core/tests/test_scalarprint.py +++ b/numpy/core/tests/test_scalarprint.py @@ -2,8 +2,6 @@ """ Test printing of scalar types. """ -from __future__ import division, absolute_import, print_function - import code, sys import platform import pytest diff --git a/numpy/core/tests/test_shape_base.py b/numpy/core/tests/test_shape_base.py index 53d272fc5c0d..723c41d6ea33 100644 --- a/numpy/core/tests/test_shape_base.py +++ b/numpy/core/tests/test_shape_base.py @@ -1,5 +1,3 @@ -from __future__ import division, absolute_import, print_function - import pytest import sys import numpy as np diff --git a/numpy/core/tests/test_ufunc.py b/numpy/core/tests/test_ufunc.py index 7109de77685c..959345785021 100644 --- a/numpy/core/tests/test_ufunc.py +++ b/numpy/core/tests/test_ufunc.py @@ -1,5 +1,3 @@ -from __future__ import division, absolute_import, print_function - import warnings import itertools diff --git a/numpy/core/tests/test_umath.py b/numpy/core/tests/test_umath.py index ae1090c23ebd..ad0bc9a54e0a 100644 --- a/numpy/core/tests/test_umath.py +++ b/numpy/core/tests/test_umath.py @@ -1,5 +1,3 @@ -from __future__ import division, absolute_import, print_function - import platform import warnings import fnmatch diff --git a/numpy/core/tests/test_umath_complex.py b/numpy/core/tests/test_umath_complex.py index 1f5b4077f68f..8c0918a88528 100644 --- a/numpy/core/tests/test_umath_complex.py +++ b/numpy/core/tests/test_umath_complex.py @@ -1,5 +1,3 @@ -from __future__ import division, absolute_import, print_function - import sys import platform import pytest diff --git a/numpy/core/tests/test_unicode.py b/numpy/core/tests/test_unicode.py index 2ffd8801b7ea..3034b491de3b 100644 --- a/numpy/core/tests/test_unicode.py +++ b/numpy/core/tests/test_unicode.py @@ -1,5 +1,3 @@ -from __future__ import division, absolute_import, print_function - import sys import numpy as np diff --git a/numpy/core/umath_tests.py b/numpy/core/umath_tests.py index 28e325b984cb..90ab17e6744a 100644 --- a/numpy/core/umath_tests.py +++ b/numpy/core/umath_tests.py @@ -2,8 +2,6 @@ Shim for _umath_tests to allow a deprecation period for the new name. """ -from __future__ import division, absolute_import, print_function - import warnings # 2018-04-04, numpy 1.15.0 diff --git a/numpy/ctypeslib.py b/numpy/ctypeslib.py index 58f3ef9d3f08..ec3cdc33d5c1 100644 --- a/numpy/ctypeslib.py +++ b/numpy/ctypeslib.py @@ -49,8 +49,6 @@ >>> _lib.foo_func(out, len(out)) #doctest: +SKIP """ -from __future__ import division, absolute_import, print_function - __all__ = ['load_library', 'ndpointer', 'ctypes_load_library', 'c_intp', 'as_ctypes', 'as_array'] diff --git a/numpy/distutils/__init__.py b/numpy/distutils/__init__.py index 8dbb63b28e4a..79974d1c220a 100644 --- a/numpy/distutils/__init__.py +++ b/numpy/distutils/__init__.py @@ -19,8 +19,6 @@ """ -from __future__ import division, absolute_import, print_function - # Must import local ccompiler ASAP in order to get # customized CCompiler.spawn effective. from . import ccompiler diff --git a/numpy/distutils/ccompiler.py b/numpy/distutils/ccompiler.py index c3a557f50e89..ef29189f78aa 100644 --- a/numpy/distutils/ccompiler.py +++ b/numpy/distutils/ccompiler.py @@ -1,5 +1,3 @@ -from __future__ import division, absolute_import, print_function - import os import re import sys diff --git a/numpy/distutils/command/__init__.py b/numpy/distutils/command/__init__.py index 76a2600723de..3ba501de03b6 100644 --- a/numpy/distutils/command/__init__.py +++ b/numpy/distutils/command/__init__.py @@ -4,8 +4,6 @@ commands. """ -from __future__ import division, absolute_import, print_function - def test_na_writable_attributes_deletion(): a = np.NA(2) attr = ['payload', 'dtype'] diff --git a/numpy/distutils/command/autodist.py b/numpy/distutils/command/autodist.py index 9c98b84d8822..1475a5e241ee 100644 --- a/numpy/distutils/command/autodist.py +++ b/numpy/distutils/command/autodist.py @@ -1,8 +1,6 @@ """This module implements additional tests ala autoconf which can be useful. """ -from __future__ import division, absolute_import, print_function - import textwrap # We put them here since they could be easily reused outside numpy.distutils diff --git a/numpy/distutils/command/bdist_rpm.py b/numpy/distutils/command/bdist_rpm.py index 3e52a503b172..682e7a8eb8e2 100644 --- a/numpy/distutils/command/bdist_rpm.py +++ b/numpy/distutils/command/bdist_rpm.py @@ -1,5 +1,3 @@ -from __future__ import division, absolute_import, print_function - import os import sys if 'setuptools' in sys.modules: diff --git a/numpy/distutils/command/build.py b/numpy/distutils/command/build.py index 5a9da1217c2b..a156a7c6ed5f 100644 --- a/numpy/distutils/command/build.py +++ b/numpy/distutils/command/build.py @@ -1,5 +1,3 @@ -from __future__ import division, absolute_import, print_function - import os import sys from distutils.command.build import build as old_build diff --git a/numpy/distutils/command/build_clib.py b/numpy/distutils/command/build_clib.py index 13edf0717798..1b4666888ca7 100644 --- a/numpy/distutils/command/build_clib.py +++ b/numpy/distutils/command/build_clib.py @@ -1,7 +1,5 @@ """ Modified version of build_clib that handles fortran source files. """ -from __future__ import division, absolute_import, print_function - import os from glob import glob import shutil diff --git a/numpy/distutils/command/build_ext.py b/numpy/distutils/command/build_ext.py index cd9b1c6f195e..a0da83ff479d 100644 --- a/numpy/distutils/command/build_ext.py +++ b/numpy/distutils/command/build_ext.py @@ -1,8 +1,6 @@ """ Modified version of build_ext that handles fortran source files. """ -from __future__ import division, absolute_import, print_function - import os import subprocess from glob import glob diff --git a/numpy/distutils/command/build_py.py b/numpy/distutils/command/build_py.py index 54dcde435083..d30dc5bf42d8 100644 --- a/numpy/distutils/command/build_py.py +++ b/numpy/distutils/command/build_py.py @@ -1,5 +1,3 @@ -from __future__ import division, absolute_import, print_function - from distutils.command.build_py import build_py as old_build_py from numpy.distutils.misc_util import is_string diff --git a/numpy/distutils/command/build_scripts.py b/numpy/distutils/command/build_scripts.py index c8b25fc719b5..d5cadb2745fe 100644 --- a/numpy/distutils/command/build_scripts.py +++ b/numpy/distutils/command/build_scripts.py @@ -1,8 +1,6 @@ """ Modified version of build_scripts that handles building scripts from functions. """ -from __future__ import division, absolute_import, print_function - from distutils.command.build_scripts import build_scripts as old_build_scripts from numpy.distutils import log from numpy.distutils.misc_util import is_string diff --git a/numpy/distutils/command/build_src.py b/numpy/distutils/command/build_src.py index 3e0522c5f82b..303d6197cbd3 100644 --- a/numpy/distutils/command/build_src.py +++ b/numpy/distutils/command/build_src.py @@ -1,7 +1,5 @@ """ Build swig and f2py sources. """ -from __future__ import division, absolute_import, print_function - import os import re import sys diff --git a/numpy/distutils/command/config.py b/numpy/distutils/command/config.py index b9f2fa76e260..bd67282816de 100644 --- a/numpy/distutils/command/config.py +++ b/numpy/distutils/command/config.py @@ -2,8 +2,6 @@ # try_compile call. try_run works but is untested for most of Fortran # compilers (they must define linker_exe first). # Pearu Peterson -from __future__ import division, absolute_import, print_function - import os, signal import warnings import sys diff --git a/numpy/distutils/command/config_compiler.py b/numpy/distutils/command/config_compiler.py index bf170063ede8..44265bfcce89 100644 --- a/numpy/distutils/command/config_compiler.py +++ b/numpy/distutils/command/config_compiler.py @@ -1,5 +1,3 @@ -from __future__ import division, absolute_import, print_function - from distutils.core import Command from numpy.distutils import log diff --git a/numpy/distutils/command/develop.py b/numpy/distutils/command/develop.py index 1410ab2a00fd..af24baf2e7e1 100644 --- a/numpy/distutils/command/develop.py +++ b/numpy/distutils/command/develop.py @@ -3,8 +3,6 @@ files with filenames. """ -from __future__ import division, absolute_import, print_function - from setuptools.command.develop import develop as old_develop class develop(old_develop): diff --git a/numpy/distutils/command/egg_info.py b/numpy/distutils/command/egg_info.py index 18673ece7d19..14c62b4d1b90 100644 --- a/numpy/distutils/command/egg_info.py +++ b/numpy/distutils/command/egg_info.py @@ -1,5 +1,3 @@ -from __future__ import division, absolute_import, print_function - import sys from setuptools.command.egg_info import egg_info as _egg_info diff --git a/numpy/distutils/command/install.py b/numpy/distutils/command/install.py index c74ae94468a0..2eff2d145047 100644 --- a/numpy/distutils/command/install.py +++ b/numpy/distutils/command/install.py @@ -1,5 +1,3 @@ -from __future__ import division, absolute_import, print_function - import sys if 'setuptools' in sys.modules: import setuptools.command.install as old_install_mod diff --git a/numpy/distutils/command/install_clib.py b/numpy/distutils/command/install_clib.py index 6a73f7e3308f..aa2e5594c3c2 100644 --- a/numpy/distutils/command/install_clib.py +++ b/numpy/distutils/command/install_clib.py @@ -1,5 +1,3 @@ -from __future__ import division, absolute_import, print_function - import os from distutils.core import Command from distutils.ccompiler import new_compiler diff --git a/numpy/distutils/command/install_data.py b/numpy/distutils/command/install_data.py index 996cf7e4017a..0a2e68ae192a 100644 --- a/numpy/distutils/command/install_data.py +++ b/numpy/distutils/command/install_data.py @@ -1,5 +1,3 @@ -from __future__ import division, absolute_import, print_function - import sys have_setuptools = ('setuptools' in sys.modules) diff --git a/numpy/distutils/command/install_headers.py b/numpy/distutils/command/install_headers.py index f3f58aa2876f..bb4ad563b2a5 100644 --- a/numpy/distutils/command/install_headers.py +++ b/numpy/distutils/command/install_headers.py @@ -1,5 +1,3 @@ -from __future__ import division, absolute_import, print_function - import os from distutils.command.install_headers import install_headers as old_install_headers diff --git a/numpy/distutils/command/sdist.py b/numpy/distutils/command/sdist.py index bfaab1c8ffa1..e34193883dea 100644 --- a/numpy/distutils/command/sdist.py +++ b/numpy/distutils/command/sdist.py @@ -1,5 +1,3 @@ -from __future__ import division, absolute_import, print_function - import sys if 'setuptools' in sys.modules: from setuptools.command.sdist import sdist as old_sdist diff --git a/numpy/distutils/compat.py b/numpy/distutils/compat.py index 9a81cd392fc4..afe0beedb013 100644 --- a/numpy/distutils/compat.py +++ b/numpy/distutils/compat.py @@ -2,8 +2,6 @@ numpy.distutils """ -from __future__ import division, absolute_import, print_function - import sys def get_exception(): diff --git a/numpy/distutils/conv_template.py b/numpy/distutils/conv_template.py index 3bcb7b8845ec..8c84ddaae008 100644 --- a/numpy/distutils/conv_template.py +++ b/numpy/distutils/conv_template.py @@ -78,8 +78,6 @@ 3, 3, jim """ -from __future__ import division, absolute_import, print_function - __all__ = ['process_str', 'process_file'] diff --git a/numpy/distutils/core.py b/numpy/distutils/core.py index 70cc37caa32b..a78bbf4843b1 100644 --- a/numpy/distutils/core.py +++ b/numpy/distutils/core.py @@ -1,5 +1,3 @@ -from __future__ import division, absolute_import, print_function - import sys from distutils.core import * diff --git a/numpy/distutils/cpuinfo.py b/numpy/distutils/cpuinfo.py index bc9728335018..73daf0d5d297 100644 --- a/numpy/distutils/cpuinfo.py +++ b/numpy/distutils/cpuinfo.py @@ -12,8 +12,6 @@ Pearu Peterson """ -from __future__ import division, absolute_import, print_function - __all__ = ['cpu'] import sys, re, types diff --git a/numpy/distutils/exec_command.py b/numpy/distutils/exec_command.py index 712f22666b39..d35b4f898496 100644 --- a/numpy/distutils/exec_command.py +++ b/numpy/distutils/exec_command.py @@ -49,8 +49,6 @@ because the messages are lost at some point. """ -from __future__ import division, absolute_import, print_function - __all__ = ['exec_command', 'find_executable'] import os diff --git a/numpy/distutils/extension.py b/numpy/distutils/extension.py index 872bd5362f2e..3b5c3db352c8 100644 --- a/numpy/distutils/extension.py +++ b/numpy/distutils/extension.py @@ -6,8 +6,6 @@ Overridden to support f2py. """ -from __future__ import division, absolute_import, print_function - import sys import re from distutils.extension import Extension as old_Extension diff --git a/numpy/distutils/fcompiler/__init__.py b/numpy/distutils/fcompiler/__init__.py index 3723470f32f4..6d99d3a616bf 100644 --- a/numpy/distutils/fcompiler/__init__.py +++ b/numpy/distutils/fcompiler/__init__.py @@ -13,8 +13,6 @@ But note that FCompiler.executables is actually a dictionary of commands. """ -from __future__ import division, absolute_import, print_function - __all__ = ['FCompiler', 'new_fcompiler', 'show_fcompilers', 'dummy_fortran_file'] diff --git a/numpy/distutils/fcompiler/absoft.py b/numpy/distutils/fcompiler/absoft.py index d14fee0e18e3..efe3a4cb55e9 100644 --- a/numpy/distutils/fcompiler/absoft.py +++ b/numpy/distutils/fcompiler/absoft.py @@ -5,8 +5,6 @@ # Notes: # - when using -g77 then use -DUNDERSCORE_G77 to compile f2py # generated extension modules (works for f2py v2.45.241_1936 and up) -from __future__ import division, absolute_import, print_function - import os from numpy.distutils.cpuinfo import cpu diff --git a/numpy/distutils/fcompiler/compaq.py b/numpy/distutils/fcompiler/compaq.py index 671b3a55f290..2088f0c9b7e6 100644 --- a/numpy/distutils/fcompiler/compaq.py +++ b/numpy/distutils/fcompiler/compaq.py @@ -1,7 +1,5 @@ #http://www.compaq.com/fortran/docs/ -from __future__ import division, absolute_import, print_function - import os import sys diff --git a/numpy/distutils/fcompiler/environment.py b/numpy/distutils/fcompiler/environment.py index bb362d483364..5d5b750ff2f5 100644 --- a/numpy/distutils/fcompiler/environment.py +++ b/numpy/distutils/fcompiler/environment.py @@ -1,5 +1,3 @@ -from __future__ import division, absolute_import, print_function - import os import warnings from distutils.dist import Distribution diff --git a/numpy/distutils/fcompiler/g95.py b/numpy/distutils/fcompiler/g95.py index e7c659b332c2..e109a972a872 100644 --- a/numpy/distutils/fcompiler/g95.py +++ b/numpy/distutils/fcompiler/g95.py @@ -1,6 +1,4 @@ # http://g95.sourceforge.net/ -from __future__ import division, absolute_import, print_function - from numpy.distutils.fcompiler import FCompiler compilers = ['G95FCompiler'] diff --git a/numpy/distutils/fcompiler/gnu.py b/numpy/distutils/fcompiler/gnu.py index 965c67041082..0a68fee72837 100644 --- a/numpy/distutils/fcompiler/gnu.py +++ b/numpy/distutils/fcompiler/gnu.py @@ -1,5 +1,3 @@ -from __future__ import division, absolute_import, print_function - import re import os import sys diff --git a/numpy/distutils/fcompiler/hpux.py b/numpy/distutils/fcompiler/hpux.py index 51bad548a124..09e6483bf5ad 100644 --- a/numpy/distutils/fcompiler/hpux.py +++ b/numpy/distutils/fcompiler/hpux.py @@ -1,5 +1,3 @@ -from __future__ import division, absolute_import, print_function - from numpy.distutils.fcompiler import FCompiler compilers = ['HPUXFCompiler'] diff --git a/numpy/distutils/fcompiler/ibm.py b/numpy/distutils/fcompiler/ibm.py index 70d2132e1491..4a83682e5165 100644 --- a/numpy/distutils/fcompiler/ibm.py +++ b/numpy/distutils/fcompiler/ibm.py @@ -1,5 +1,3 @@ -from __future__ import division, absolute_import, print_function - import os import re import sys diff --git a/numpy/distutils/fcompiler/intel.py b/numpy/distutils/fcompiler/intel.py index 51f6812743a2..d84f38c76a64 100644 --- a/numpy/distutils/fcompiler/intel.py +++ b/numpy/distutils/fcompiler/intel.py @@ -1,6 +1,4 @@ # http://developer.intel.com/software/products/compilers/flin/ -from __future__ import division, absolute_import, print_function - import sys from numpy.distutils.ccompiler import simple_version_match diff --git a/numpy/distutils/fcompiler/lahey.py b/numpy/distutils/fcompiler/lahey.py index 1beb662f4e93..e925838268b8 100644 --- a/numpy/distutils/fcompiler/lahey.py +++ b/numpy/distutils/fcompiler/lahey.py @@ -1,5 +1,3 @@ -from __future__ import division, absolute_import, print_function - import os from numpy.distutils.fcompiler import FCompiler diff --git a/numpy/distutils/fcompiler/mips.py b/numpy/distutils/fcompiler/mips.py index da337b24a3ff..a0973804571b 100644 --- a/numpy/distutils/fcompiler/mips.py +++ b/numpy/distutils/fcompiler/mips.py @@ -1,5 +1,3 @@ -from __future__ import division, absolute_import, print_function - from numpy.distutils.cpuinfo import cpu from numpy.distutils.fcompiler import FCompiler diff --git a/numpy/distutils/fcompiler/nag.py b/numpy/distutils/fcompiler/nag.py index cb71d548cd2d..908e724e6536 100644 --- a/numpy/distutils/fcompiler/nag.py +++ b/numpy/distutils/fcompiler/nag.py @@ -1,5 +1,3 @@ -from __future__ import division, absolute_import, print_function - import sys import re from numpy.distutils.fcompiler import FCompiler diff --git a/numpy/distutils/fcompiler/none.py b/numpy/distutils/fcompiler/none.py index bdeea1560e91..ef411fffc7cb 100644 --- a/numpy/distutils/fcompiler/none.py +++ b/numpy/distutils/fcompiler/none.py @@ -1,5 +1,3 @@ -from __future__ import division, absolute_import, print_function - from numpy.distutils.fcompiler import FCompiler from numpy.distutils import customized_fcompiler diff --git a/numpy/distutils/fcompiler/pathf95.py b/numpy/distutils/fcompiler/pathf95.py index 5de86f63aee6..0768cb12e87a 100644 --- a/numpy/distutils/fcompiler/pathf95.py +++ b/numpy/distutils/fcompiler/pathf95.py @@ -1,5 +1,3 @@ -from __future__ import division, absolute_import, print_function - from numpy.distutils.fcompiler import FCompiler compilers = ['PathScaleFCompiler'] diff --git a/numpy/distutils/fcompiler/pg.py b/numpy/distutils/fcompiler/pg.py index 9c51947fd803..77bc4f08edce 100644 --- a/numpy/distutils/fcompiler/pg.py +++ b/numpy/distutils/fcompiler/pg.py @@ -1,6 +1,4 @@ # http://www.pgroup.com -from __future__ import division, absolute_import, print_function - import sys from numpy.distutils.fcompiler import FCompiler, dummy_fortran_file diff --git a/numpy/distutils/fcompiler/sun.py b/numpy/distutils/fcompiler/sun.py index 561ea854f982..d039f0b25705 100644 --- a/numpy/distutils/fcompiler/sun.py +++ b/numpy/distutils/fcompiler/sun.py @@ -1,5 +1,3 @@ -from __future__ import division, absolute_import, print_function - from numpy.distutils.ccompiler import simple_version_match from numpy.distutils.fcompiler import FCompiler diff --git a/numpy/distutils/fcompiler/vast.py b/numpy/distutils/fcompiler/vast.py index adc1591bde91..92a1647ba437 100644 --- a/numpy/distutils/fcompiler/vast.py +++ b/numpy/distutils/fcompiler/vast.py @@ -1,5 +1,3 @@ -from __future__ import division, absolute_import, print_function - import os from numpy.distutils.fcompiler.gnu import GnuFCompiler diff --git a/numpy/distutils/from_template.py b/numpy/distutils/from_template.py index c5c1163c63c4..b4dd05b5e602 100644 --- a/numpy/distutils/from_template.py +++ b/numpy/distutils/from_template.py @@ -45,8 +45,6 @@ """ -from __future__ import division, absolute_import, print_function - __all__ = ['process_str', 'process_file'] import os diff --git a/numpy/distutils/intelccompiler.py b/numpy/distutils/intelccompiler.py index 3386775ee56a..0388ad577518 100644 --- a/numpy/distutils/intelccompiler.py +++ b/numpy/distutils/intelccompiler.py @@ -1,5 +1,3 @@ -from __future__ import division, absolute_import, print_function - import platform from distutils.unixccompiler import UnixCCompiler diff --git a/numpy/distutils/lib2def.py b/numpy/distutils/lib2def.py index 2d013a1e3d41..c6d445d09388 100644 --- a/numpy/distutils/lib2def.py +++ b/numpy/distutils/lib2def.py @@ -1,5 +1,3 @@ -from __future__ import division, absolute_import, print_function - import re import sys import subprocess diff --git a/numpy/distutils/line_endings.py b/numpy/distutils/line_endings.py index fe8fd1b0fe6a..92a84e56a2e9 100644 --- a/numpy/distutils/line_endings.py +++ b/numpy/distutils/line_endings.py @@ -1,8 +1,6 @@ """ Functions for converting from DOS to UNIX line endings """ -from __future__ import division, absolute_import, print_function - import sys, re, os def dos2unix(file): diff --git a/numpy/distutils/log.py b/numpy/distutils/log.py index ff7de86b1147..ec1100b1b225 100644 --- a/numpy/distutils/log.py +++ b/numpy/distutils/log.py @@ -1,6 +1,4 @@ # Colored log, requires Python 2.3 or up. -from __future__ import division, absolute_import, print_function - import sys from distutils.log import * from distutils.log import Log as old_Log diff --git a/numpy/distutils/mingw32ccompiler.py b/numpy/distutils/mingw32ccompiler.py index 075858cfe09e..e2cd1c19bc26 100644 --- a/numpy/distutils/mingw32ccompiler.py +++ b/numpy/distutils/mingw32ccompiler.py @@ -7,8 +7,6 @@ # 3. Force windows to use g77 """ -from __future__ import division, absolute_import, print_function - import os import sys import subprocess diff --git a/numpy/distutils/misc_util.py b/numpy/distutils/misc_util.py index d46ff89813b9..e75e620b006c 100644 --- a/numpy/distutils/misc_util.py +++ b/numpy/distutils/misc_util.py @@ -1,5 +1,3 @@ -from __future__ import division, absolute_import, print_function - import os import re import sys diff --git a/numpy/distutils/msvc9compiler.py b/numpy/distutils/msvc9compiler.py index e9cc334a5ec4..68239495d6c7 100644 --- a/numpy/distutils/msvc9compiler.py +++ b/numpy/distutils/msvc9compiler.py @@ -1,5 +1,3 @@ -from __future__ import division, absolute_import, print_function - import os from distutils.msvc9compiler import MSVCCompiler as _MSVCCompiler diff --git a/numpy/distutils/msvccompiler.py b/numpy/distutils/msvccompiler.py index 0cb4bf9794be..681a254b87ee 100644 --- a/numpy/distutils/msvccompiler.py +++ b/numpy/distutils/msvccompiler.py @@ -1,5 +1,3 @@ -from __future__ import division, absolute_import, print_function - import os from distutils.msvccompiler import MSVCCompiler as _MSVCCompiler diff --git a/numpy/distutils/npy_pkg_config.py b/numpy/distutils/npy_pkg_config.py index 48584b4c41c7..377a24e41a9e 100644 --- a/numpy/distutils/npy_pkg_config.py +++ b/numpy/distutils/npy_pkg_config.py @@ -1,5 +1,3 @@ -from __future__ import division, absolute_import, print_function - import sys import re import os diff --git a/numpy/distutils/numpy_distribution.py b/numpy/distutils/numpy_distribution.py index 6ae19d16b18f..ea8182659cb1 100644 --- a/numpy/distutils/numpy_distribution.py +++ b/numpy/distutils/numpy_distribution.py @@ -1,6 +1,4 @@ # XXX: Handle setuptools ? -from __future__ import division, absolute_import, print_function - from distutils.core import Distribution # This class is used because we add new files (sconscripts, and so on) with the diff --git a/numpy/distutils/pathccompiler.py b/numpy/distutils/pathccompiler.py index fc9872db34da..48051810ee21 100644 --- a/numpy/distutils/pathccompiler.py +++ b/numpy/distutils/pathccompiler.py @@ -1,5 +1,3 @@ -from __future__ import division, absolute_import, print_function - from distutils.unixccompiler import UnixCCompiler class PathScaleCCompiler(UnixCCompiler): diff --git a/numpy/distutils/setup.py b/numpy/distutils/setup.py index 82a53bd08dbe..415d2adeb5ee 100644 --- a/numpy/distutils/setup.py +++ b/numpy/distutils/setup.py @@ -1,6 +1,4 @@ #!/usr/bin/env python -from __future__ import division, print_function - def configuration(parent_package='',top_path=None): from numpy.distutils.misc_util import Configuration config = Configuration('distutils', parent_package, top_path) diff --git a/numpy/distutils/system_info.py b/numpy/distutils/system_info.py index fc7018af3490..a2ab04b88183 100644 --- a/numpy/distutils/system_info.py +++ b/numpy/distutils/system_info.py @@ -128,8 +128,6 @@ NO WARRANTY IS EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK. """ -from __future__ import division, absolute_import, print_function - import sys import os import re diff --git a/numpy/distutils/tests/test_ccompiler.py b/numpy/distutils/tests/test_ccompiler.py index 8b4a56b79085..72aa8227c1f3 100644 --- a/numpy/distutils/tests/test_ccompiler.py +++ b/numpy/distutils/tests/test_ccompiler.py @@ -1,5 +1,3 @@ -from __future__ import division, absolute_import, print_function - from distutils.ccompiler import new_compiler from numpy.distutils.numpy_distribution import NumpyDistribution diff --git a/numpy/distutils/tests/test_exec_command.py b/numpy/distutils/tests/test_exec_command.py index 37912f5ba9d8..8c3a4516a9fb 100644 --- a/numpy/distutils/tests/test_exec_command.py +++ b/numpy/distutils/tests/test_exec_command.py @@ -1,5 +1,3 @@ -from __future__ import division, absolute_import, print_function - import os import sys from tempfile import TemporaryFile diff --git a/numpy/distutils/tests/test_fcompiler.py b/numpy/distutils/tests/test_fcompiler.py index 6d245fbd4b69..c559becf8ad2 100644 --- a/numpy/distutils/tests/test_fcompiler.py +++ b/numpy/distutils/tests/test_fcompiler.py @@ -1,5 +1,3 @@ -from __future__ import division, absolute_import, print_function - import pytest from numpy.testing import assert_, suppress_warnings diff --git a/numpy/distutils/tests/test_fcompiler_gnu.py b/numpy/distutils/tests/test_fcompiler_gnu.py index 49208aaced34..b7bba2f95941 100644 --- a/numpy/distutils/tests/test_fcompiler_gnu.py +++ b/numpy/distutils/tests/test_fcompiler_gnu.py @@ -1,5 +1,3 @@ -from __future__ import division, absolute_import, print_function - from numpy.testing import assert_ import numpy.distutils.fcompiler diff --git a/numpy/distutils/tests/test_fcompiler_intel.py b/numpy/distutils/tests/test_fcompiler_intel.py index 5e014bada34f..3bb81e0274e4 100644 --- a/numpy/distutils/tests/test_fcompiler_intel.py +++ b/numpy/distutils/tests/test_fcompiler_intel.py @@ -1,5 +1,3 @@ -from __future__ import division, absolute_import, print_function - import numpy.distutils.fcompiler from numpy.testing import assert_ diff --git a/numpy/distutils/tests/test_fcompiler_nagfor.py b/numpy/distutils/tests/test_fcompiler_nagfor.py index 1c936056a89b..785aeda148a8 100644 --- a/numpy/distutils/tests/test_fcompiler_nagfor.py +++ b/numpy/distutils/tests/test_fcompiler_nagfor.py @@ -1,5 +1,3 @@ -from __future__ import division, absolute_import, print_function - from numpy.testing import assert_ import numpy.distutils.fcompiler diff --git a/numpy/distutils/tests/test_misc_util.py b/numpy/distutils/tests/test_misc_util.py index 3e239cf48cba..a584e0869d8f 100644 --- a/numpy/distutils/tests/test_misc_util.py +++ b/numpy/distutils/tests/test_misc_util.py @@ -1,5 +1,3 @@ -from __future__ import division, absolute_import, print_function - from os.path import join, sep, dirname from numpy.distutils.misc_util import ( diff --git a/numpy/distutils/tests/test_npy_pkg_config.py b/numpy/distutils/tests/test_npy_pkg_config.py index 537e16e90d2a..d202fce852d9 100644 --- a/numpy/distutils/tests/test_npy_pkg_config.py +++ b/numpy/distutils/tests/test_npy_pkg_config.py @@ -1,5 +1,3 @@ -from __future__ import division, absolute_import, print_function - import os from numpy.distutils.npy_pkg_config import read_config, parse_flags diff --git a/numpy/distutils/tests/test_shell_utils.py b/numpy/distutils/tests/test_shell_utils.py index a0344244fe9c..754609a5d806 100644 --- a/numpy/distutils/tests/test_shell_utils.py +++ b/numpy/distutils/tests/test_shell_utils.py @@ -1,5 +1,3 @@ -from __future__ import division, absolute_import, print_function - import pytest import subprocess import os diff --git a/numpy/distutils/tests/test_system_info.py b/numpy/distutils/tests/test_system_info.py index 3c7638960c7c..04f5f8320026 100644 --- a/numpy/distutils/tests/test_system_info.py +++ b/numpy/distutils/tests/test_system_info.py @@ -1,5 +1,3 @@ -from __future__ import division, print_function - import os import shutil import pytest diff --git a/numpy/distutils/unixccompiler.py b/numpy/distutils/unixccompiler.py index 11b2cce529af..23db2a81469f 100644 --- a/numpy/distutils/unixccompiler.py +++ b/numpy/distutils/unixccompiler.py @@ -2,8 +2,6 @@ unixccompiler - can handle very long argument lists for ar. """ -from __future__ import division, absolute_import, print_function - import os from distutils.errors import DistutilsExecError, CompileError diff --git a/numpy/doc/__init__.py b/numpy/doc/__init__.py index b6f1fa71c54a..8a944fecd865 100644 --- a/numpy/doc/__init__.py +++ b/numpy/doc/__init__.py @@ -1,5 +1,3 @@ -from __future__ import division, absolute_import, print_function - import os ref_dir = os.path.join(os.path.dirname(__file__)) diff --git a/numpy/doc/basics.py b/numpy/doc/basics.py index c05f347a1f46..635c1b1b8e65 100644 --- a/numpy/doc/basics.py +++ b/numpy/doc/basics.py @@ -339,4 +339,3 @@ ``1 + np.finfo(np.longdouble).eps``. """ -from __future__ import division, absolute_import, print_function diff --git a/numpy/doc/broadcasting.py b/numpy/doc/broadcasting.py index cb548a0d064c..63975e6a9367 100644 --- a/numpy/doc/broadcasting.py +++ b/numpy/doc/broadcasting.py @@ -178,4 +178,3 @@ with ``b``, which has shape ``(3,)``, yields a ``4x3`` array. """ -from __future__ import division, absolute_import, print_function diff --git a/numpy/doc/byteswapping.py b/numpy/doc/byteswapping.py index 7a749c8d5513..fe9461977971 100644 --- a/numpy/doc/byteswapping.py +++ b/numpy/doc/byteswapping.py @@ -153,4 +153,3 @@ False """ -from __future__ import division, absolute_import, print_function diff --git a/numpy/doc/constants.py b/numpy/doc/constants.py index 72793e44dcc8..96813b66c239 100644 --- a/numpy/doc/constants.py +++ b/numpy/doc/constants.py @@ -13,8 +13,6 @@ # # Note: the docstring is autogenerated. # -from __future__ import division, absolute_import, print_function - import textwrap, re # Maintain same format as in numpy.add_newdocs diff --git a/numpy/doc/creation.py b/numpy/doc/creation.py index 9ebe938be000..067f8bb336ad 100644 --- a/numpy/doc/creation.py +++ b/numpy/doc/creation.py @@ -141,4 +141,3 @@ diagonal). """ -from __future__ import division, absolute_import, print_function diff --git a/numpy/doc/glossary.py b/numpy/doc/glossary.py index 7d1c9a1d5d15..2431516a817d 100644 --- a/numpy/doc/glossary.py +++ b/numpy/doc/glossary.py @@ -473,4 +473,3 @@ and f2py (which wraps Fortran). """ -from __future__ import division, absolute_import, print_function diff --git a/numpy/doc/indexing.py b/numpy/doc/indexing.py index 676015668241..aa84e2b112cb 100644 --- a/numpy/doc/indexing.py +++ b/numpy/doc/indexing.py @@ -446,4 +446,3 @@ 40 """ -from __future__ import division, absolute_import, print_function diff --git a/numpy/doc/internals.py b/numpy/doc/internals.py index a14fee7c2fff..6718f1108dc4 100644 --- a/numpy/doc/internals.py +++ b/numpy/doc/internals.py @@ -160,4 +160,3 @@ it is more in line with Python semantics and the natural order of the data. """ -from __future__ import division, absolute_import, print_function diff --git a/numpy/doc/misc.py b/numpy/doc/misc.py index a76abe164f33..fc1c4cd0122a 100644 --- a/numpy/doc/misc.py +++ b/numpy/doc/misc.py @@ -224,4 +224,3 @@ 5) SIP (used mainly in PyQT) """ -from __future__ import division, absolute_import, print_function diff --git a/numpy/doc/structured_arrays.py b/numpy/doc/structured_arrays.py index 1343d2adc1f9..72990cf891e5 100644 --- a/numpy/doc/structured_arrays.py +++ b/numpy/doc/structured_arrays.py @@ -644,4 +644,3 @@ will still be accessible by index. """ -from __future__ import division, absolute_import, print_function diff --git a/numpy/doc/subclassing.py b/numpy/doc/subclassing.py index d0685328e29f..7ef426f5b31f 100644 --- a/numpy/doc/subclassing.py +++ b/numpy/doc/subclassing.py @@ -750,4 +750,3 @@ def sum(self, axis=None, dtype=None, **unused_kwargs): ``**unused_kwargs`` parameter. """ -from __future__ import division, absolute_import, print_function diff --git a/numpy/doc/ufuncs.py b/numpy/doc/ufuncs.py index df2c455ec21f..eecc15083d53 100644 --- a/numpy/doc/ufuncs.py +++ b/numpy/doc/ufuncs.py @@ -135,4 +135,3 @@ a convenient way to apply these operators. """ -from __future__ import division, absolute_import, print_function diff --git a/numpy/dual.py b/numpy/dual.py index 651e845bbd5c..92afec52df90 100644 --- a/numpy/dual.py +++ b/numpy/dual.py @@ -10,8 +10,6 @@ .. _Scipy : https://www.scipy.org """ -from __future__ import division, absolute_import, print_function - # This module should be used for functions both in numpy and scipy if # you want to use the numpy version if available but the scipy version # otherwise. diff --git a/numpy/f2py/__init__.py b/numpy/f2py/__init__.py index 42e3632fdf3e..13ffef6fc5b5 100644 --- a/numpy/f2py/__init__.py +++ b/numpy/f2py/__init__.py @@ -2,8 +2,6 @@ """Fortran to Python Interface Generator. """ -from __future__ import division, absolute_import, print_function - __all__ = ['run_main', 'compile', 'f2py_testing'] import sys diff --git a/numpy/f2py/__main__.py b/numpy/f2py/__main__.py index 708f7f3624ad..c6115070e4cc 100644 --- a/numpy/f2py/__main__.py +++ b/numpy/f2py/__main__.py @@ -1,6 +1,4 @@ # See http://cens.ioc.ee/projects/f2py2e/ -from __future__ import division, print_function - from numpy.f2py.f2py2e import main main() diff --git a/numpy/f2py/__version__.py b/numpy/f2py/__version__.py index 49a2199bf38b..104c2e1a899e 100644 --- a/numpy/f2py/__version__.py +++ b/numpy/f2py/__version__.py @@ -1,5 +1,3 @@ -from __future__ import division, absolute_import, print_function - major = 2 try: diff --git a/numpy/f2py/auxfuncs.py b/numpy/f2py/auxfuncs.py index 404bdbd2d62a..d985e6e36363 100644 --- a/numpy/f2py/auxfuncs.py +++ b/numpy/f2py/auxfuncs.py @@ -14,8 +14,6 @@ Pearu Peterson """ -from __future__ import division, absolute_import, print_function - import pprint import sys import types diff --git a/numpy/f2py/capi_maps.py b/numpy/f2py/capi_maps.py index 917a4a9a3ad1..6f9ff7bc6f9e 100644 --- a/numpy/f2py/capi_maps.py +++ b/numpy/f2py/capi_maps.py @@ -11,8 +11,6 @@ Pearu Peterson """ -from __future__ import division, absolute_import, print_function - __version__ = "$Revision: 1.60 $"[10:-1] from . import __version__ diff --git a/numpy/f2py/cb_rules.py b/numpy/f2py/cb_rules.py index 183d7c2f920b..dc178078d5b5 100644 --- a/numpy/f2py/cb_rules.py +++ b/numpy/f2py/cb_rules.py @@ -13,8 +13,6 @@ Pearu Peterson """ -from __future__ import division, absolute_import, print_function - from . import __version__ from .auxfuncs import ( applyrules, debugcapi, dictappend, errmess, getargs, hasnote, isarray, diff --git a/numpy/f2py/cfuncs.py b/numpy/f2py/cfuncs.py index cede0611950a..e11774e97996 100644 --- a/numpy/f2py/cfuncs.py +++ b/numpy/f2py/cfuncs.py @@ -14,8 +14,6 @@ Pearu Peterson """ -from __future__ import division, absolute_import, print_function - import sys import copy diff --git a/numpy/f2py/common_rules.py b/numpy/f2py/common_rules.py index f61d8810a181..31aefcda928b 100644 --- a/numpy/f2py/common_rules.py +++ b/numpy/f2py/common_rules.py @@ -13,8 +13,6 @@ Pearu Peterson """ -from __future__ import division, absolute_import, print_function - __version__ = "$Revision: 1.19 $"[10:-1] from . import __version__ diff --git a/numpy/f2py/crackfortran.py b/numpy/f2py/crackfortran.py index 2db4a47e86ca..910120e00e4e 100755 --- a/numpy/f2py/crackfortran.py +++ b/numpy/f2py/crackfortran.py @@ -138,8 +138,6 @@ The above may be solved by creating appropriate preprocessor program, for example. """ -from __future__ import division, absolute_import, print_function - import sys import string import fileinput diff --git a/numpy/f2py/diagnose.py b/numpy/f2py/diagnose.py index 0241fed12ffe..092368c82eb5 100644 --- a/numpy/f2py/diagnose.py +++ b/numpy/f2py/diagnose.py @@ -1,6 +1,4 @@ #!/usr/bin/env python -from __future__ import division, absolute_import, print_function - import os import sys import tempfile diff --git a/numpy/f2py/f2py2e.py b/numpy/f2py/f2py2e.py index d03eff9e31b2..a6751154be2b 100755 --- a/numpy/f2py/f2py2e.py +++ b/numpy/f2py/f2py2e.py @@ -14,8 +14,6 @@ Pearu Peterson """ -from __future__ import division, absolute_import, print_function - import sys import os import pprint diff --git a/numpy/f2py/f2py_testing.py b/numpy/f2py/f2py_testing.py index f5d5fa63d03f..1f109e67a5e2 100644 --- a/numpy/f2py/f2py_testing.py +++ b/numpy/f2py/f2py_testing.py @@ -1,5 +1,3 @@ -from __future__ import division, absolute_import, print_function - import sys import re diff --git a/numpy/f2py/f90mod_rules.py b/numpy/f2py/f90mod_rules.py index 85eae8047928..ad96591c0a43 100644 --- a/numpy/f2py/f90mod_rules.py +++ b/numpy/f2py/f90mod_rules.py @@ -13,8 +13,6 @@ Pearu Peterson """ -from __future__ import division, absolute_import, print_function - __version__ = "$Revision: 1.27 $"[10:-1] f2py_version = 'See `f2py -v`' diff --git a/numpy/f2py/func2subr.py b/numpy/f2py/func2subr.py index 6010d5a231af..8e18a3236b76 100644 --- a/numpy/f2py/func2subr.py +++ b/numpy/f2py/func2subr.py @@ -13,8 +13,6 @@ Pearu Peterson """ -from __future__ import division, absolute_import, print_function - __version__ = "$Revision: 1.16 $"[10:-1] f2py_version = 'See `f2py -v`' diff --git a/numpy/f2py/rules.py b/numpy/f2py/rules.py index 28eb9da30871..3e84de2a6e8a 100755 --- a/numpy/f2py/rules.py +++ b/numpy/f2py/rules.py @@ -50,8 +50,6 @@ Pearu Peterson """ -from __future__ import division, absolute_import, print_function - __version__ = "$Revision: 1.129 $"[10:-1] from . import __version__ diff --git a/numpy/f2py/setup.py b/numpy/f2py/setup.py index a8c1401aaa9f..5e4d7cd56973 100644 --- a/numpy/f2py/setup.py +++ b/numpy/f2py/setup.py @@ -16,8 +16,6 @@ Pearu Peterson """ -from __future__ import division, print_function - from numpy.distutils.core import setup from numpy.distutils.misc_util import Configuration diff --git a/numpy/f2py/tests/test_array_from_pyobj.py b/numpy/f2py/tests/test_array_from_pyobj.py index a80090185d0f..c5757dba13c0 100644 --- a/numpy/f2py/tests/test_array_from_pyobj.py +++ b/numpy/f2py/tests/test_array_from_pyobj.py @@ -1,5 +1,3 @@ -from __future__ import division, absolute_import, print_function - import os import sys import copy diff --git a/numpy/f2py/tests/test_assumed_shape.py b/numpy/f2py/tests/test_assumed_shape.py index e5695a61c11a..dfc252660c59 100644 --- a/numpy/f2py/tests/test_assumed_shape.py +++ b/numpy/f2py/tests/test_assumed_shape.py @@ -1,5 +1,3 @@ -from __future__ import division, absolute_import, print_function - import os import pytest import tempfile diff --git a/numpy/f2py/tests/test_block_docstring.py b/numpy/f2py/tests/test_block_docstring.py index 4f1678980f8b..03660f021dfc 100644 --- a/numpy/f2py/tests/test_block_docstring.py +++ b/numpy/f2py/tests/test_block_docstring.py @@ -1,5 +1,3 @@ -from __future__ import division, absolute_import, print_function - import sys import pytest from . import util diff --git a/numpy/f2py/tests/test_callback.py b/numpy/f2py/tests/test_callback.py index 21c29ba5f8a8..e4e61f450388 100644 --- a/numpy/f2py/tests/test_callback.py +++ b/numpy/f2py/tests/test_callback.py @@ -1,5 +1,3 @@ -from __future__ import division, absolute_import, print_function - import math import textwrap import sys diff --git a/numpy/f2py/tests/test_common.py b/numpy/f2py/tests/test_common.py index dcb01b0ec736..e4bf35504761 100644 --- a/numpy/f2py/tests/test_common.py +++ b/numpy/f2py/tests/test_common.py @@ -1,5 +1,3 @@ -from __future__ import division, absolute_import, print_function - import os import sys import pytest diff --git a/numpy/f2py/tests/test_compile_function.py b/numpy/f2py/tests/test_compile_function.py index 40ea7997f7d7..d40ed63cfc45 100644 --- a/numpy/f2py/tests/test_compile_function.py +++ b/numpy/f2py/tests/test_compile_function.py @@ -1,8 +1,6 @@ """See https://github.com/numpy/numpy/pull/11937. """ -from __future__ import division, absolute_import, print_function - import sys import os import uuid diff --git a/numpy/f2py/tests/test_crackfortran.py b/numpy/f2py/tests/test_crackfortran.py index 941696be398e..796965e6f4f4 100644 --- a/numpy/f2py/tests/test_crackfortran.py +++ b/numpy/f2py/tests/test_crackfortran.py @@ -1,5 +1,3 @@ -from __future__ import division, absolute_import, print_function - import pytest import numpy as np @@ -37,4 +35,3 @@ def test_module(self): self.module.subc([w, k]) assert_array_equal(k, w + 1) assert self.module.t0(23) == b'2' - diff --git a/numpy/f2py/tests/test_kind.py b/numpy/f2py/tests/test_kind.py index 1f7762a805f2..a7e2b28ed37c 100644 --- a/numpy/f2py/tests/test_kind.py +++ b/numpy/f2py/tests/test_kind.py @@ -1,5 +1,3 @@ -from __future__ import division, absolute_import, print_function - import os import pytest diff --git a/numpy/f2py/tests/test_mixed.py b/numpy/f2py/tests/test_mixed.py index 0337538ff1ef..fc00ccc4328b 100644 --- a/numpy/f2py/tests/test_mixed.py +++ b/numpy/f2py/tests/test_mixed.py @@ -1,5 +1,3 @@ -from __future__ import division, absolute_import, print_function - import os import textwrap import pytest diff --git a/numpy/f2py/tests/test_parameter.py b/numpy/f2py/tests/test_parameter.py index 6a378687ad78..b6182716987b 100644 --- a/numpy/f2py/tests/test_parameter.py +++ b/numpy/f2py/tests/test_parameter.py @@ -1,5 +1,3 @@ -from __future__ import division, absolute_import, print_function - import os import pytest diff --git a/numpy/f2py/tests/test_quoted_character.py b/numpy/f2py/tests/test_quoted_character.py index c9a1c36f50cb..d89ef1385539 100644 --- a/numpy/f2py/tests/test_quoted_character.py +++ b/numpy/f2py/tests/test_quoted_character.py @@ -1,8 +1,6 @@ """See https://github.com/numpy/numpy/pull/10676. """ -from __future__ import division, absolute_import, print_function - import sys from importlib import import_module import pytest diff --git a/numpy/f2py/tests/test_regression.py b/numpy/f2py/tests/test_regression.py index 3adae635d9ac..67e00f1f7820 100644 --- a/numpy/f2py/tests/test_regression.py +++ b/numpy/f2py/tests/test_regression.py @@ -1,5 +1,3 @@ -from __future__ import division, absolute_import, print_function - import os import pytest diff --git a/numpy/f2py/tests/test_return_character.py b/numpy/f2py/tests/test_return_character.py index fc3a58d36b8a..6cb95a8b6e44 100644 --- a/numpy/f2py/tests/test_return_character.py +++ b/numpy/f2py/tests/test_return_character.py @@ -1,5 +1,3 @@ -from __future__ import division, absolute_import, print_function - import pytest from numpy import array diff --git a/numpy/f2py/tests/test_return_complex.py b/numpy/f2py/tests/test_return_complex.py index 43c884dfb0d5..9063695bcae1 100644 --- a/numpy/f2py/tests/test_return_complex.py +++ b/numpy/f2py/tests/test_return_complex.py @@ -1,5 +1,3 @@ -from __future__ import division, absolute_import, print_function - import pytest from numpy import array diff --git a/numpy/f2py/tests/test_return_integer.py b/numpy/f2py/tests/test_return_integer.py index 22f4acfdf6d1..35f32e37d223 100644 --- a/numpy/f2py/tests/test_return_integer.py +++ b/numpy/f2py/tests/test_return_integer.py @@ -1,5 +1,3 @@ -from __future__ import division, absolute_import, print_function - import pytest from numpy import array diff --git a/numpy/f2py/tests/test_return_logical.py b/numpy/f2py/tests/test_return_logical.py index 96f215a914fd..3139e0df7b03 100644 --- a/numpy/f2py/tests/test_return_logical.py +++ b/numpy/f2py/tests/test_return_logical.py @@ -1,5 +1,3 @@ -from __future__ import division, absolute_import, print_function - import pytest from numpy import array diff --git a/numpy/f2py/tests/test_return_real.py b/numpy/f2py/tests/test_return_real.py index 315cfe49b9b5..1707aab45aba 100644 --- a/numpy/f2py/tests/test_return_real.py +++ b/numpy/f2py/tests/test_return_real.py @@ -1,5 +1,3 @@ -from __future__ import division, absolute_import, print_function - import platform import pytest diff --git a/numpy/f2py/tests/test_semicolon_split.py b/numpy/f2py/tests/test_semicolon_split.py index bcd18c893fc2..d8b4bf222122 100644 --- a/numpy/f2py/tests/test_semicolon_split.py +++ b/numpy/f2py/tests/test_semicolon_split.py @@ -1,5 +1,3 @@ -from __future__ import division, absolute_import, print_function - import platform import pytest diff --git a/numpy/f2py/tests/test_size.py b/numpy/f2py/tests/test_size.py index e2af6180489b..b609fa77f711 100644 --- a/numpy/f2py/tests/test_size.py +++ b/numpy/f2py/tests/test_size.py @@ -1,5 +1,3 @@ -from __future__ import division, absolute_import, print_function - import os import pytest diff --git a/numpy/f2py/tests/test_string.py b/numpy/f2py/tests/test_string.py index 0493c99cf1dd..e3ec96af9ff4 100644 --- a/numpy/f2py/tests/test_string.py +++ b/numpy/f2py/tests/test_string.py @@ -1,5 +1,3 @@ -from __future__ import division, absolute_import, print_function - import os import pytest diff --git a/numpy/f2py/tests/util.py b/numpy/f2py/tests/util.py index bf005df882ae..c4fcea8d1f8c 100644 --- a/numpy/f2py/tests/util.py +++ b/numpy/f2py/tests/util.py @@ -5,8 +5,6 @@ - detecting if compilers are present """ -from __future__ import division, absolute_import, print_function - import os import sys import subprocess diff --git a/numpy/f2py/use_rules.py b/numpy/f2py/use_rules.py index 6f44f16345bd..268c7e81b984 100644 --- a/numpy/f2py/use_rules.py +++ b/numpy/f2py/use_rules.py @@ -15,8 +15,6 @@ Pearu Peterson """ -from __future__ import division, absolute_import, print_function - __version__ = "$Revision: 1.3 $"[10:-1] f2py_version = 'See `f2py -v`' diff --git a/numpy/fft/__init__.py b/numpy/fft/__init__.py index 37b3f0da6543..36cfe81b38eb 100644 --- a/numpy/fft/__init__.py +++ b/numpy/fft/__init__.py @@ -191,8 +191,6 @@ """ -from __future__ import division, absolute_import, print_function - from ._pocketfft import * from .helper import * diff --git a/numpy/fft/_pocketfft.py b/numpy/fft/_pocketfft.py index 50720cda4d23..f2510a6c2ca1 100644 --- a/numpy/fft/_pocketfft.py +++ b/numpy/fft/_pocketfft.py @@ -27,8 +27,6 @@ behavior.) """ -from __future__ import division, absolute_import, print_function - __all__ = ['fft', 'ifft', 'rfft', 'irfft', 'hfft', 'ihfft', 'rfftn', 'irfftn', 'rfft2', 'irfft2', 'fft2', 'ifft2', 'fftn', 'ifftn'] diff --git a/numpy/fft/helper.py b/numpy/fft/helper.py index a920a4ac08d8..3dacd9ee1a92 100644 --- a/numpy/fft/helper.py +++ b/numpy/fft/helper.py @@ -2,8 +2,6 @@ Discrete Fourier Transforms - helper.py """ -from __future__ import division, absolute_import, print_function - from numpy.compat import integer_types from numpy.core import integer, empty, arange, asarray, roll from numpy.core.overrides import array_function_dispatch, set_module diff --git a/numpy/fft/setup.py b/numpy/fft/setup.py index 8c3a315577b5..40d632ec55ef 100644 --- a/numpy/fft/setup.py +++ b/numpy/fft/setup.py @@ -1,5 +1,3 @@ -from __future__ import division, print_function - def configuration(parent_package='',top_path=None): from numpy.distutils.misc_util import Configuration diff --git a/numpy/fft/tests/test_helper.py b/numpy/fft/tests/test_helper.py index 6613c8002306..dd24139f2f0e 100644 --- a/numpy/fft/tests/test_helper.py +++ b/numpy/fft/tests/test_helper.py @@ -3,7 +3,6 @@ Copied from fftpack.helper by Pearu Peterson, October 2005 """ -from __future__ import division, absolute_import, print_function import numpy as np from numpy.testing import assert_array_almost_equal, assert_equal from numpy import fft, pi diff --git a/numpy/fft/tests/test_pocketfft.py b/numpy/fft/tests/test_pocketfft.py index 453e964fa753..0aa8d0912f00 100644 --- a/numpy/fft/tests/test_pocketfft.py +++ b/numpy/fft/tests/test_pocketfft.py @@ -1,5 +1,3 @@ -from __future__ import division, absolute_import, print_function - import numpy as np import pytest from numpy.random import random diff --git a/numpy/lib/__init__.py b/numpy/lib/__init__.py index 2db12d9a4d0b..cb0de0d155db 100644 --- a/numpy/lib/__init__.py +++ b/numpy/lib/__init__.py @@ -11,8 +11,6 @@ useful to have in the main name-space. """ -from __future__ import division, absolute_import, print_function - import math from numpy.version import version as __version__ diff --git a/numpy/lib/_datasource.py b/numpy/lib/_datasource.py index 0d71375c28c3..8d1b8339a09c 100644 --- a/numpy/lib/_datasource.py +++ b/numpy/lib/_datasource.py @@ -34,8 +34,6 @@ >>> fp.close() # doctest: +SKIP """ -from __future__ import division, absolute_import, print_function - import os import sys import warnings diff --git a/numpy/lib/_iotools.py b/numpy/lib/_iotools.py index 8bc336fdb38b..f612cbe94d28 100644 --- a/numpy/lib/_iotools.py +++ b/numpy/lib/_iotools.py @@ -1,8 +1,6 @@ """A collection of functions designed to help I/O with ascii files. """ -from __future__ import division, absolute_import, print_function - __docformat__ = "restructuredtext en" import numpy as np diff --git a/numpy/lib/_version.py b/numpy/lib/_version.py index 8aa999fc9251..6a7c5cba1d77 100644 --- a/numpy/lib/_version.py +++ b/numpy/lib/_version.py @@ -5,8 +5,6 @@ work; they don't recognize anything like alpha/beta/rc/dev versions. """ -from __future__ import division, absolute_import, print_function - import re from numpy.compat import basestring diff --git a/numpy/lib/arraypad.py b/numpy/lib/arraypad.py index 33e64708d545..247eed07c271 100644 --- a/numpy/lib/arraypad.py +++ b/numpy/lib/arraypad.py @@ -3,8 +3,6 @@ of an n-dimensional array. """ -from __future__ import division, absolute_import, print_function - import numpy as np from numpy.core.overrides import array_function_dispatch from numpy.lib.index_tricks import ndindex diff --git a/numpy/lib/arraysetops.py b/numpy/lib/arraysetops.py index d65316598d69..ad508e85d9b3 100644 --- a/numpy/lib/arraysetops.py +++ b/numpy/lib/arraysetops.py @@ -25,8 +25,6 @@ :Author: Robert Cimrman """ -from __future__ import division, absolute_import, print_function - import functools import numpy as np diff --git a/numpy/lib/arrayterator.py b/numpy/lib/arrayterator.py index c166685825ed..0727c7a3eb55 100644 --- a/numpy/lib/arrayterator.py +++ b/numpy/lib/arrayterator.py @@ -7,8 +7,6 @@ a user-specified number of elements. """ -from __future__ import division, absolute_import, print_function - from operator import mul from functools import reduce diff --git a/numpy/lib/financial.py b/numpy/lib/financial.py index a011e52a9eb0..b055bb1ec789 100644 --- a/numpy/lib/financial.py +++ b/numpy/lib/financial.py @@ -10,8 +10,6 @@ Functions support the :class:`decimal.Decimal` type unless otherwise stated. """ -from __future__ import division, absolute_import, print_function - import warnings from decimal import Decimal import functools diff --git a/numpy/lib/format.py b/numpy/lib/format.py index 20e2e9c729ab..2ee43637cdf2 100644 --- a/numpy/lib/format.py +++ b/numpy/lib/format.py @@ -161,8 +161,6 @@ evolved with time and this document is more current. """ -from __future__ import division, absolute_import, print_function - import numpy import sys import io diff --git a/numpy/lib/function_base.py b/numpy/lib/function_base.py index 4c3de4df9941..3b0a6783bd7f 100644 --- a/numpy/lib/function_base.py +++ b/numpy/lib/function_base.py @@ -1,5 +1,3 @@ -from __future__ import division, absolute_import, print_function - try: # Accessing collections abstract classes from collections # has been deprecated since Python 3.3 diff --git a/numpy/lib/histograms.py b/numpy/lib/histograms.py index 03c365ab6e3c..0eff73b39d05 100644 --- a/numpy/lib/histograms.py +++ b/numpy/lib/histograms.py @@ -1,8 +1,6 @@ """ Histogram-related functions """ -from __future__ import division, absolute_import, print_function - import contextlib import functools import operator diff --git a/numpy/lib/index_tricks.py b/numpy/lib/index_tricks.py index 04384854c74c..f6a6f922c24f 100644 --- a/numpy/lib/index_tricks.py +++ b/numpy/lib/index_tricks.py @@ -1,5 +1,3 @@ -from __future__ import division, absolute_import, print_function - import functools import sys import math diff --git a/numpy/lib/mixins.py b/numpy/lib/mixins.py index f974a7724e4d..dd17adb41a52 100644 --- a/numpy/lib/mixins.py +++ b/numpy/lib/mixins.py @@ -1,6 +1,4 @@ """Mixin classes for custom array types that don't inherit from ndarray.""" -from __future__ import division, absolute_import, print_function - import sys from numpy.core import umath as um diff --git a/numpy/lib/nanfunctions.py b/numpy/lib/nanfunctions.py index 8e2a34e707d1..00355043257d 100644 --- a/numpy/lib/nanfunctions.py +++ b/numpy/lib/nanfunctions.py @@ -20,8 +20,6 @@ - `nanpercentile` -- qth percentile of non-NaN values """ -from __future__ import division, absolute_import, print_function - import functools import warnings import numpy as np diff --git a/numpy/lib/npyio.py b/numpy/lib/npyio.py index 3e54ff10c253..c85db2922db3 100644 --- a/numpy/lib/npyio.py +++ b/numpy/lib/npyio.py @@ -1,5 +1,3 @@ -from __future__ import division, absolute_import, print_function - import sys import os import re diff --git a/numpy/lib/polynomial.py b/numpy/lib/polynomial.py index 3d07a0de430b..c2b615e0e843 100644 --- a/numpy/lib/polynomial.py +++ b/numpy/lib/polynomial.py @@ -2,8 +2,6 @@ Functions to operate on polynomials. """ -from __future__ import division, absolute_import, print_function - __all__ = ['poly', 'roots', 'polyint', 'polyder', 'polyadd', 'polysub', 'polymul', 'polydiv', 'polyval', 'poly1d', 'polyfit', 'RankWarning'] diff --git a/numpy/lib/recfunctions.py b/numpy/lib/recfunctions.py index 927161ddb01b..93aa67a3b3fd 100644 --- a/numpy/lib/recfunctions.py +++ b/numpy/lib/recfunctions.py @@ -5,8 +5,6 @@ matplotlib. They have been rewritten and extended for convenience. """ -from __future__ import division, absolute_import, print_function - import sys import itertools import numpy as np diff --git a/numpy/lib/scimath.py b/numpy/lib/scimath.py index 5ac790ce9f51..555a3d5a844e 100644 --- a/numpy/lib/scimath.py +++ b/numpy/lib/scimath.py @@ -15,8 +15,6 @@ correctly handled. See their respective docstrings for specific examples. """ -from __future__ import division, absolute_import, print_function - import numpy.core.numeric as nx import numpy.core.numerictypes as nt from numpy.core.numeric import asarray, any diff --git a/numpy/lib/setup.py b/numpy/lib/setup.py index d342410b8a85..5d0341d86e55 100644 --- a/numpy/lib/setup.py +++ b/numpy/lib/setup.py @@ -1,5 +1,3 @@ -from __future__ import division, print_function - def configuration(parent_package='',top_path=None): from numpy.distutils.misc_util import Configuration diff --git a/numpy/lib/shape_base.py b/numpy/lib/shape_base.py index dbb61c2251f8..7634af0106b9 100644 --- a/numpy/lib/shape_base.py +++ b/numpy/lib/shape_base.py @@ -1,5 +1,3 @@ -from __future__ import division, absolute_import, print_function - import functools import numpy.core.numeric as _nx diff --git a/numpy/lib/stride_tricks.py b/numpy/lib/stride_tricks.py index 8aafd094b02c..b65706dd5bcc 100644 --- a/numpy/lib/stride_tricks.py +++ b/numpy/lib/stride_tricks.py @@ -5,8 +5,6 @@ NumPy reference guide. """ -from __future__ import division, absolute_import, print_function - import numpy as np from numpy.core.overrides import array_function_dispatch diff --git a/numpy/lib/tests/test__datasource.py b/numpy/lib/tests/test__datasource.py index 8eac16b589a0..e7c14b80786a 100644 --- a/numpy/lib/tests/test__datasource.py +++ b/numpy/lib/tests/test__datasource.py @@ -1,5 +1,3 @@ -from __future__ import division, absolute_import, print_function - import os import sys import pytest diff --git a/numpy/lib/tests/test__iotools.py b/numpy/lib/tests/test__iotools.py index 15cd3ad9d8d9..24c2533e8889 100644 --- a/numpy/lib/tests/test__iotools.py +++ b/numpy/lib/tests/test__iotools.py @@ -1,5 +1,3 @@ -from __future__ import division, absolute_import, print_function - import time from datetime import date diff --git a/numpy/lib/tests/test__version.py b/numpy/lib/tests/test__version.py index 8e66a0c0323f..1825046316a9 100644 --- a/numpy/lib/tests/test__version.py +++ b/numpy/lib/tests/test__version.py @@ -1,8 +1,6 @@ """Tests for the NumpyVersion class. """ -from __future__ import division, absolute_import, print_function - from numpy.testing import assert_, assert_raises from numpy.lib import NumpyVersion diff --git a/numpy/lib/tests/test_arraypad.py b/numpy/lib/tests/test_arraypad.py index 65593dd29922..6ae3ef5c0d36 100644 --- a/numpy/lib/tests/test_arraypad.py +++ b/numpy/lib/tests/test_arraypad.py @@ -1,8 +1,6 @@ """Tests for the array padding functions. """ -from __future__ import division, absolute_import, print_function - import pytest import numpy as np diff --git a/numpy/lib/tests/test_arraysetops.py b/numpy/lib/tests/test_arraysetops.py index 1d38d8d27981..992a37cef307 100644 --- a/numpy/lib/tests/test_arraysetops.py +++ b/numpy/lib/tests/test_arraysetops.py @@ -1,8 +1,6 @@ """Test functions for 1D array set operations. """ -from __future__ import division, absolute_import, print_function - import numpy as np from numpy.testing import (assert_array_equal, assert_equal, diff --git a/numpy/lib/tests/test_arrayterator.py b/numpy/lib/tests/test_arrayterator.py index 2ce4456a5b5c..c00ed13d7f30 100644 --- a/numpy/lib/tests/test_arrayterator.py +++ b/numpy/lib/tests/test_arrayterator.py @@ -1,5 +1,3 @@ -from __future__ import division, absolute_import, print_function - from operator import mul from functools import reduce diff --git a/numpy/lib/tests/test_financial.py b/numpy/lib/tests/test_financial.py index cb67f7c0f621..e7a71c722e95 100644 --- a/numpy/lib/tests/test_financial.py +++ b/numpy/lib/tests/test_financial.py @@ -1,5 +1,3 @@ -from __future__ import division, absolute_import, print_function - import warnings from decimal import Decimal diff --git a/numpy/lib/tests/test_format.py b/numpy/lib/tests/test_format.py index 0592e0b12592..28ce038aec02 100644 --- a/numpy/lib/tests/test_format.py +++ b/numpy/lib/tests/test_format.py @@ -1,5 +1,3 @@ -from __future__ import division, absolute_import, print_function - # doctest r''' Test the .npy file format. diff --git a/numpy/lib/tests/test_function_base.py b/numpy/lib/tests/test_function_base.py index 77e8f03f9a24..42a8c591c06d 100644 --- a/numpy/lib/tests/test_function_base.py +++ b/numpy/lib/tests/test_function_base.py @@ -1,5 +1,3 @@ -from __future__ import division, absolute_import, print_function - import operator import warnings import sys diff --git a/numpy/lib/tests/test_histograms.py b/numpy/lib/tests/test_histograms.py index dbf189f3e5e1..a78c3f4ec05e 100644 --- a/numpy/lib/tests/test_histograms.py +++ b/numpy/lib/tests/test_histograms.py @@ -1,5 +1,3 @@ -from __future__ import division, absolute_import, print_function - import numpy as np from numpy.lib.histograms import histogram, histogramdd, histogram_bin_edges diff --git a/numpy/lib/tests/test_index_tricks.py b/numpy/lib/tests/test_index_tricks.py index dbe445c2c37d..bfc37ef9c2d7 100644 --- a/numpy/lib/tests/test_index_tricks.py +++ b/numpy/lib/tests/test_index_tricks.py @@ -1,5 +1,3 @@ -from __future__ import division, absolute_import, print_function - import pytest import numpy as np diff --git a/numpy/lib/tests/test_io.py b/numpy/lib/tests/test_io.py index a095e250af05..12ce65984cc7 100644 --- a/numpy/lib/tests/test_io.py +++ b/numpy/lib/tests/test_io.py @@ -1,5 +1,3 @@ -from __future__ import division, absolute_import, print_function - import sys import gzip import os diff --git a/numpy/lib/tests/test_mixins.py b/numpy/lib/tests/test_mixins.py index 3dd5346b695c..948268e44c09 100644 --- a/numpy/lib/tests/test_mixins.py +++ b/numpy/lib/tests/test_mixins.py @@ -1,5 +1,3 @@ -from __future__ import division, absolute_import, print_function - import numbers import operator import sys diff --git a/numpy/lib/tests/test_nanfunctions.py b/numpy/lib/tests/test_nanfunctions.py index da2d0cc52b6b..b0a7a04eede5 100644 --- a/numpy/lib/tests/test_nanfunctions.py +++ b/numpy/lib/tests/test_nanfunctions.py @@ -1,5 +1,3 @@ -from __future__ import division, absolute_import, print_function - import warnings import pytest diff --git a/numpy/lib/tests/test_packbits.py b/numpy/lib/tests/test_packbits.py index 95a465c36a6a..5b07f41c6260 100644 --- a/numpy/lib/tests/test_packbits.py +++ b/numpy/lib/tests/test_packbits.py @@ -1,5 +1,3 @@ -from __future__ import division, absolute_import, print_function - import numpy as np from numpy.testing import assert_array_equal, assert_equal, assert_raises import pytest diff --git a/numpy/lib/tests/test_polynomial.py b/numpy/lib/tests/test_polynomial.py index 89759bd83949..0d827eadf062 100644 --- a/numpy/lib/tests/test_polynomial.py +++ b/numpy/lib/tests/test_polynomial.py @@ -1,5 +1,3 @@ -from __future__ import division, absolute_import, print_function - import numpy as np from numpy.testing import ( assert_, assert_equal, assert_array_equal, assert_almost_equal, diff --git a/numpy/lib/tests/test_recfunctions.py b/numpy/lib/tests/test_recfunctions.py index 53229e31a389..cb4efa6c32c6 100644 --- a/numpy/lib/tests/test_recfunctions.py +++ b/numpy/lib/tests/test_recfunctions.py @@ -1,5 +1,3 @@ -from __future__ import division, absolute_import, print_function - import pytest import numpy as np diff --git a/numpy/lib/tests/test_regression.py b/numpy/lib/tests/test_regression.py index 4cd812f5dc10..6de89103a730 100644 --- a/numpy/lib/tests/test_regression.py +++ b/numpy/lib/tests/test_regression.py @@ -1,5 +1,3 @@ -from __future__ import division, absolute_import, print_function - import os import sys diff --git a/numpy/lib/tests/test_shape_base.py b/numpy/lib/tests/test_shape_base.py index ff9019e3d072..86e3744b8bf9 100644 --- a/numpy/lib/tests/test_shape_base.py +++ b/numpy/lib/tests/test_shape_base.py @@ -1,5 +1,3 @@ -from __future__ import division, absolute_import, print_function - import numpy as np import functools import sys diff --git a/numpy/lib/tests/test_stride_tricks.py b/numpy/lib/tests/test_stride_tricks.py index 85fcceedc1e3..6131ba5e1524 100644 --- a/numpy/lib/tests/test_stride_tricks.py +++ b/numpy/lib/tests/test_stride_tricks.py @@ -1,5 +1,3 @@ -from __future__ import division, absolute_import, print_function - import numpy as np from numpy.core._rational_tests import rational from numpy.testing import ( diff --git a/numpy/lib/tests/test_twodim_base.py b/numpy/lib/tests/test_twodim_base.py index bb844e4bd6a6..1377794f6585 100644 --- a/numpy/lib/tests/test_twodim_base.py +++ b/numpy/lib/tests/test_twodim_base.py @@ -1,8 +1,6 @@ """Test functions for matrix module """ -from __future__ import division, absolute_import, print_function - from numpy.testing import ( assert_equal, assert_array_equal, assert_array_max_ulp, assert_array_almost_equal, assert_raises, assert_ diff --git a/numpy/lib/tests/test_type_check.py b/numpy/lib/tests/test_type_check.py index b3f114b92968..a8af147f1443 100644 --- a/numpy/lib/tests/test_type_check.py +++ b/numpy/lib/tests/test_type_check.py @@ -1,5 +1,3 @@ -from __future__ import division, absolute_import, print_function - import numpy as np from numpy.compat import long from numpy.testing import ( diff --git a/numpy/lib/tests/test_ufunclike.py b/numpy/lib/tests/test_ufunclike.py index 64280616f2bc..527e093e6851 100644 --- a/numpy/lib/tests/test_ufunclike.py +++ b/numpy/lib/tests/test_ufunclike.py @@ -1,5 +1,3 @@ -from __future__ import division, absolute_import, print_function - import numpy as np import numpy.core as nx import numpy.lib.ufunclike as ufl diff --git a/numpy/lib/tests/test_utils.py b/numpy/lib/tests/test_utils.py index 9673a05fa12d..20b394912f48 100644 --- a/numpy/lib/tests/test_utils.py +++ b/numpy/lib/tests/test_utils.py @@ -1,5 +1,3 @@ -from __future__ import division, absolute_import, print_function - import inspect import sys import pytest diff --git a/numpy/lib/twodim_base.py b/numpy/lib/twodim_base.py index 2e6d30a1d18e..320a24856bc1 100644 --- a/numpy/lib/twodim_base.py +++ b/numpy/lib/twodim_base.py @@ -1,8 +1,6 @@ """ Basic functions for manipulating 2d arrays """ -from __future__ import division, absolute_import, print_function - import functools from numpy.core.numeric import ( diff --git a/numpy/lib/type_check.py b/numpy/lib/type_check.py index 9771172352c9..13db9adc300d 100644 --- a/numpy/lib/type_check.py +++ b/numpy/lib/type_check.py @@ -1,7 +1,6 @@ """Automatically adapted for numpy Sep 19, 2005 by convertcode.py """ -from __future__ import division, absolute_import, print_function import functools import warnings diff --git a/numpy/lib/ufunclike.py b/numpy/lib/ufunclike.py index 9f03b13291c6..8512669c2070 100644 --- a/numpy/lib/ufunclike.py +++ b/numpy/lib/ufunclike.py @@ -3,8 +3,6 @@ storing results in an output array. """ -from __future__ import division, absolute_import, print_function - __all__ = ['fix', 'isneginf', 'isposinf'] import numpy.core.numeric as nx diff --git a/numpy/lib/user_array.py b/numpy/lib/user_array.py index f1510a7b11c9..9172d42497f6 100644 --- a/numpy/lib/user_array.py +++ b/numpy/lib/user_array.py @@ -5,8 +5,6 @@ complete. """ -from __future__ import division, absolute_import, print_function - from numpy.core import ( array, asarray, absolute, add, subtract, multiply, divide, remainder, power, left_shift, right_shift, bitwise_and, bitwise_or, diff --git a/numpy/lib/utils.py b/numpy/lib/utils.py index 3c71d2a7c8be..8b335a9d8d10 100644 --- a/numpy/lib/utils.py +++ b/numpy/lib/utils.py @@ -1,5 +1,3 @@ -from __future__ import division, absolute_import, print_function - import os import sys import types diff --git a/numpy/linalg/__init__.py b/numpy/linalg/__init__.py index 55560815d005..3a53ac6ecac6 100644 --- a/numpy/linalg/__init__.py +++ b/numpy/linalg/__init__.py @@ -69,8 +69,6 @@ LinAlgError """ -from __future__ import division, absolute_import, print_function - # To get sub-modules from .linalg import * diff --git a/numpy/linalg/lapack_lite/clapack_scrub.py b/numpy/linalg/lapack_lite/clapack_scrub.py index 4345861131f8..427ccdd14c5e 100644 --- a/numpy/linalg/lapack_lite/clapack_scrub.py +++ b/numpy/linalg/lapack_lite/clapack_scrub.py @@ -1,6 +1,4 @@ #!/usr/bin/env python -from __future__ import division, absolute_import, print_function - import sys, os import re from plex import Scanner, Str, Lexicon, Opt, Bol, State, AnyChar, TEXT, IGNORE diff --git a/numpy/linalg/lapack_lite/fortran.py b/numpy/linalg/lapack_lite/fortran.py index 671f14d24c45..34bcdbd4e420 100644 --- a/numpy/linalg/lapack_lite/fortran.py +++ b/numpy/linalg/lapack_lite/fortran.py @@ -1,5 +1,3 @@ -from __future__ import division, absolute_import, print_function - import re import itertools diff --git a/numpy/linalg/lapack_lite/make_lite.py b/numpy/linalg/lapack_lite/make_lite.py index 61102d6ab07e..bbed177eeaad 100755 --- a/numpy/linalg/lapack_lite/make_lite.py +++ b/numpy/linalg/lapack_lite/make_lite.py @@ -11,8 +11,6 @@ * patch """ -from __future__ import division, absolute_import, print_function - import sys import os import subprocess diff --git a/numpy/linalg/linalg.py b/numpy/linalg/linalg.py index 072670d5c3b6..15615e1a3828 100644 --- a/numpy/linalg/linalg.py +++ b/numpy/linalg/linalg.py @@ -8,8 +8,6 @@ dgeev, zgeev, dgesdd, zgesdd, dgelsd, zgelsd, dsyevd, zheevd, dgetrf, zgetrf, dpotrf, zpotrf, dgeqrf, zgeqrf, zungqr, dorgqr. """ -from __future__ import division, absolute_import, print_function - __all__ = ['matrix_power', 'solve', 'tensorsolve', 'tensorinv', 'inv', 'cholesky', 'eigvals', 'eigvalsh', 'pinv', 'slogdet', 'det', diff --git a/numpy/linalg/setup.py b/numpy/linalg/setup.py index 0aa0566d6ff6..66eed41b0bf3 100644 --- a/numpy/linalg/setup.py +++ b/numpy/linalg/setup.py @@ -1,5 +1,3 @@ -from __future__ import division, print_function - import os import sys diff --git a/numpy/linalg/tests/test_build.py b/numpy/linalg/tests/test_build.py index 921390da3314..9517b3701268 100644 --- a/numpy/linalg/tests/test_build.py +++ b/numpy/linalg/tests/test_build.py @@ -1,5 +1,3 @@ -from __future__ import division, absolute_import, print_function - from subprocess import PIPE, Popen import sys import re diff --git a/numpy/linalg/tests/test_deprecations.py b/numpy/linalg/tests/test_deprecations.py index e12755e0d586..cd4c10832e7e 100644 --- a/numpy/linalg/tests/test_deprecations.py +++ b/numpy/linalg/tests/test_deprecations.py @@ -1,8 +1,6 @@ """Test deprecation and future warnings. """ -from __future__ import division, absolute_import, print_function - import numpy as np from numpy.testing import assert_warns diff --git a/numpy/linalg/tests/test_linalg.py b/numpy/linalg/tests/test_linalg.py index ef05b595ea9d..92ee6d2f35fd 100644 --- a/numpy/linalg/tests/test_linalg.py +++ b/numpy/linalg/tests/test_linalg.py @@ -1,8 +1,6 @@ """ Test functions for linalg module """ -from __future__ import division, absolute_import, print_function - import os import sys import itertools diff --git a/numpy/linalg/tests/test_regression.py b/numpy/linalg/tests/test_regression.py index bd3a45872cb1..4671dfee775b 100644 --- a/numpy/linalg/tests/test_regression.py +++ b/numpy/linalg/tests/test_regression.py @@ -1,7 +1,5 @@ """ Test functions for linalg module """ -from __future__ import division, absolute_import, print_function - import warnings import numpy as np diff --git a/numpy/ma/__init__.py b/numpy/ma/__init__.py index 36ceb1f6e7ae..870cc4ef2daa 100644 --- a/numpy/ma/__init__.py +++ b/numpy/ma/__init__.py @@ -39,8 +39,6 @@ .. moduleauthor:: Jarrod Millman """ -from __future__ import division, absolute_import, print_function - from . import core from .core import * diff --git a/numpy/ma/bench.py b/numpy/ma/bench.py index a9ba42deae40..a1363d4d9a05 100644 --- a/numpy/ma/bench.py +++ b/numpy/ma/bench.py @@ -1,8 +1,6 @@ #! /usr/bin/env python # -*- coding: utf-8 -*- -from __future__ import division, print_function - import timeit import numpy diff --git a/numpy/ma/core.py b/numpy/ma/core.py index 2baf547a423a..3fa0d63b33bf 100644 --- a/numpy/ma/core.py +++ b/numpy/ma/core.py @@ -20,8 +20,6 @@ """ # pylint: disable-msg=E1002 -from __future__ import division, absolute_import, print_function - import sys import operator import warnings diff --git a/numpy/ma/extras.py b/numpy/ma/extras.py index f4a914471970..221e648c5ded 100644 --- a/numpy/ma/extras.py +++ b/numpy/ma/extras.py @@ -8,8 +8,6 @@ :version: $Id: extras.py 3473 2007-10-29 15:18:13Z jarrod.millman $ """ -from __future__ import division, absolute_import, print_function - __all__ = [ 'apply_along_axis', 'apply_over_axes', 'atleast_1d', 'atleast_2d', 'atleast_3d', 'average', 'clump_masked', 'clump_unmasked', diff --git a/numpy/ma/mrecords.py b/numpy/ma/mrecords.py index ae1a12c2cbd8..83520d6b937d 100644 --- a/numpy/ma/mrecords.py +++ b/numpy/ma/mrecords.py @@ -8,8 +8,6 @@ .. moduleauthor:: Pierre Gerard-Marchant """ -from __future__ import division, absolute_import, print_function - # We should make sure that no field is called '_mask','mask','_fieldmask', # or whatever restricted keywords. An idea would be to no bother in the # first place, and then rename the invalid fields with a trailing diff --git a/numpy/ma/setup.py b/numpy/ma/setup.py index d1d6c89b5139..af1e419b4847 100644 --- a/numpy/ma/setup.py +++ b/numpy/ma/setup.py @@ -1,6 +1,4 @@ #!/usr/bin/env python -from __future__ import division, print_function - def configuration(parent_package='',top_path=None): from numpy.distutils.misc_util import Configuration config = Configuration('ma', parent_package, top_path) diff --git a/numpy/ma/tests/test_core.py b/numpy/ma/tests/test_core.py index b72ce56aa299..31f973e686af 100644 --- a/numpy/ma/tests/test_core.py +++ b/numpy/ma/tests/test_core.py @@ -4,8 +4,6 @@ :author: Pierre Gerard-Marchant :contact: pierregm_at_uga_dot_edu """ -from __future__ import division, absolute_import, print_function - __author__ = "Pierre GF Gerard-Marchant" import sys diff --git a/numpy/ma/tests/test_deprecations.py b/numpy/ma/tests/test_deprecations.py index 72cc29aa046e..7f44a2176414 100644 --- a/numpy/ma/tests/test_deprecations.py +++ b/numpy/ma/tests/test_deprecations.py @@ -1,8 +1,6 @@ """Test deprecation and future warnings. """ -from __future__ import division, absolute_import, print_function - import numpy as np from numpy.testing import assert_warns from numpy.ma.testutils import assert_equal diff --git a/numpy/ma/tests/test_extras.py b/numpy/ma/tests/test_extras.py index c75c47801bf4..c36bcbbbb954 100644 --- a/numpy/ma/tests/test_extras.py +++ b/numpy/ma/tests/test_extras.py @@ -7,8 +7,6 @@ :version: $Id: test_extras.py 3473 2007-10-29 15:18:13Z jarrod.millman $ """ -from __future__ import division, absolute_import, print_function - import warnings import itertools import pytest diff --git a/numpy/ma/tests/test_mrecords.py b/numpy/ma/tests/test_mrecords.py index 94e772d5571d..14d39d9490fc 100644 --- a/numpy/ma/tests/test_mrecords.py +++ b/numpy/ma/tests/test_mrecords.py @@ -5,8 +5,6 @@ :contact: pierregm_at_uga_dot_edu """ -from __future__ import division, absolute_import, print_function - import numpy as np import numpy.ma as ma from numpy import recarray diff --git a/numpy/ma/tests/test_old_ma.py b/numpy/ma/tests/test_old_ma.py index 7100eccbbe82..5d5046c0961f 100644 --- a/numpy/ma/tests/test_old_ma.py +++ b/numpy/ma/tests/test_old_ma.py @@ -1,5 +1,3 @@ -from __future__ import division, absolute_import, print_function - from functools import reduce import numpy as np diff --git a/numpy/ma/tests/test_regression.py b/numpy/ma/tests/test_regression.py index b83873a5a181..32e8e30c145c 100644 --- a/numpy/ma/tests/test_regression.py +++ b/numpy/ma/tests/test_regression.py @@ -1,5 +1,3 @@ -from __future__ import division, absolute_import, print_function - import numpy as np from numpy.testing import ( assert_, assert_array_equal, assert_allclose, suppress_warnings diff --git a/numpy/ma/tests/test_subclassing.py b/numpy/ma/tests/test_subclassing.py index 440b367224a5..781079371142 100644 --- a/numpy/ma/tests/test_subclassing.py +++ b/numpy/ma/tests/test_subclassing.py @@ -6,8 +6,6 @@ :version: $Id: test_subclassing.py 3473 2007-10-29 15:18:13Z jarrod.millman $ """ -from __future__ import division, absolute_import, print_function - import numpy as np from numpy.testing import assert_, assert_raises from numpy.ma.testutils import assert_equal diff --git a/numpy/ma/testutils.py b/numpy/ma/testutils.py index c0deaa9f4884..51ab03948ebc 100644 --- a/numpy/ma/testutils.py +++ b/numpy/ma/testutils.py @@ -5,8 +5,6 @@ :version: $Id: testutils.py 3529 2007-11-13 08:01:14Z jarrod.millman $ """ -from __future__ import division, absolute_import, print_function - import operator import numpy as np diff --git a/numpy/ma/timer_comparison.py b/numpy/ma/timer_comparison.py index 4ad635e38edc..fc63c18b5bdc 100644 --- a/numpy/ma/timer_comparison.py +++ b/numpy/ma/timer_comparison.py @@ -1,5 +1,3 @@ -from __future__ import division, absolute_import, print_function - import timeit from functools import reduce diff --git a/numpy/matlib.py b/numpy/matlib.py index b1b15558645f..f3eb8eb4b992 100644 --- a/numpy/matlib.py +++ b/numpy/matlib.py @@ -1,5 +1,3 @@ -from __future__ import division, absolute_import, print_function - import numpy as np from numpy.matrixlib.defmatrix import matrix, asmatrix # need * as we're copying the numpy namespace (FIXME: this makes little sense) diff --git a/numpy/matrixlib/__init__.py b/numpy/matrixlib/__init__.py index 777e0cd33909..54154d11f750 100644 --- a/numpy/matrixlib/__init__.py +++ b/numpy/matrixlib/__init__.py @@ -1,8 +1,6 @@ """Sub-package containing the matrix class and related functions. """ -from __future__ import division, absolute_import, print_function - from .defmatrix import * __all__ = defmatrix.__all__ diff --git a/numpy/matrixlib/defmatrix.py b/numpy/matrixlib/defmatrix.py index cabd41367e83..12ac74cb2477 100644 --- a/numpy/matrixlib/defmatrix.py +++ b/numpy/matrixlib/defmatrix.py @@ -1,5 +1,3 @@ -from __future__ import division, absolute_import, print_function - __all__ = ['matrix', 'bmat', 'mat', 'asmatrix'] import sys diff --git a/numpy/matrixlib/setup.py b/numpy/matrixlib/setup.py index d0981d6584b7..c4eee4be4029 100644 --- a/numpy/matrixlib/setup.py +++ b/numpy/matrixlib/setup.py @@ -1,6 +1,4 @@ #!/usr/bin/env python -from __future__ import division, print_function - def configuration(parent_package='', top_path=None): from numpy.distutils.misc_util import Configuration config = Configuration('matrixlib', parent_package, top_path) diff --git a/numpy/matrixlib/tests/test_defmatrix.py b/numpy/matrixlib/tests/test_defmatrix.py index aa6e08d64de2..68151833b757 100644 --- a/numpy/matrixlib/tests/test_defmatrix.py +++ b/numpy/matrixlib/tests/test_defmatrix.py @@ -1,5 +1,3 @@ -from __future__ import division, absolute_import, print_function - try: # Accessing collections abstract classes from collections # has been deprecated since Python 3.3 diff --git a/numpy/matrixlib/tests/test_interaction.py b/numpy/matrixlib/tests/test_interaction.py index 088ae3c6a661..c0b1a9fc19c7 100644 --- a/numpy/matrixlib/tests/test_interaction.py +++ b/numpy/matrixlib/tests/test_interaction.py @@ -2,8 +2,6 @@ Note that tests with MaskedArray and linalg are done in separate files. """ -from __future__ import division, absolute_import, print_function - import pytest import textwrap diff --git a/numpy/matrixlib/tests/test_masked_matrix.py b/numpy/matrixlib/tests/test_masked_matrix.py index d3911d2e1053..ab70be6ff614 100644 --- a/numpy/matrixlib/tests/test_masked_matrix.py +++ b/numpy/matrixlib/tests/test_masked_matrix.py @@ -1,5 +1,3 @@ -from __future__ import division, absolute_import, print_function - import numpy as np from numpy.ma.testutils import (assert_, assert_equal, assert_raises, assert_array_equal) diff --git a/numpy/matrixlib/tests/test_matrix_linalg.py b/numpy/matrixlib/tests/test_matrix_linalg.py index 6fc733c2e91c..106c2e38217a 100644 --- a/numpy/matrixlib/tests/test_matrix_linalg.py +++ b/numpy/matrixlib/tests/test_matrix_linalg.py @@ -1,6 +1,4 @@ """ Test functions for linalg module using the matrix class.""" -from __future__ import division, absolute_import, print_function - import numpy as np from numpy.linalg.tests.test_linalg import ( diff --git a/numpy/matrixlib/tests/test_multiarray.py b/numpy/matrixlib/tests/test_multiarray.py index 6d84bd4777a5..d34c6de0dc91 100644 --- a/numpy/matrixlib/tests/test_multiarray.py +++ b/numpy/matrixlib/tests/test_multiarray.py @@ -1,5 +1,3 @@ -from __future__ import division, absolute_import, print_function - import numpy as np from numpy.testing import assert_, assert_equal, assert_array_equal diff --git a/numpy/matrixlib/tests/test_numeric.py b/numpy/matrixlib/tests/test_numeric.py index 95e1c800177d..7e4b4d304db6 100644 --- a/numpy/matrixlib/tests/test_numeric.py +++ b/numpy/matrixlib/tests/test_numeric.py @@ -1,5 +1,3 @@ -from __future__ import division, absolute_import, print_function - import numpy as np from numpy.testing import assert_equal diff --git a/numpy/matrixlib/tests/test_regression.py b/numpy/matrixlib/tests/test_regression.py index 70e1472793fa..187286dd78f0 100644 --- a/numpy/matrixlib/tests/test_regression.py +++ b/numpy/matrixlib/tests/test_regression.py @@ -1,5 +1,3 @@ -from __future__ import division, absolute_import, print_function - import numpy as np from numpy.testing import assert_, assert_equal, assert_raises diff --git a/numpy/polynomial/__init__.py b/numpy/polynomial/__init__.py index 85cee9ce6bf4..4ff2df57ea05 100644 --- a/numpy/polynomial/__init__.py +++ b/numpy/polynomial/__init__.py @@ -13,8 +13,6 @@ information can be found in the docstring for the module of interest. """ -from __future__ import division, absolute_import, print_function - from .polynomial import Polynomial from .chebyshev import Chebyshev from .legendre import Legendre diff --git a/numpy/polynomial/_polybase.py b/numpy/polynomial/_polybase.py index bfa030714613..28bd50ec6c86 100644 --- a/numpy/polynomial/_polybase.py +++ b/numpy/polynomial/_polybase.py @@ -6,8 +6,6 @@ abc module from the stdlib, hence it is only available for Python >= 2.6. """ -from __future__ import division, absolute_import, print_function - import abc import numbers diff --git a/numpy/polynomial/chebyshev.py b/numpy/polynomial/chebyshev.py index 0cd9c4d23edd..0bb2978072d4 100644 --- a/numpy/polynomial/chebyshev.py +++ b/numpy/polynomial/chebyshev.py @@ -87,8 +87,6 @@ (preprint: https://www.math.hmc.edu/~benjamin/papers/CombTrig.pdf, pg. 4) """ -from __future__ import division, absolute_import, print_function - import warnings import numpy as np import numpy.linalg as la diff --git a/numpy/polynomial/hermite.py b/numpy/polynomial/hermite.py index 9b1aea239763..cb98b7e1f932 100644 --- a/numpy/polynomial/hermite.py +++ b/numpy/polynomial/hermite.py @@ -58,8 +58,6 @@ `numpy.polynomial` """ -from __future__ import division, absolute_import, print_function - import warnings import numpy as np import numpy.linalg as la diff --git a/numpy/polynomial/hermite_e.py b/numpy/polynomial/hermite_e.py index c5a0a05a2c88..1f4a93c24e0c 100644 --- a/numpy/polynomial/hermite_e.py +++ b/numpy/polynomial/hermite_e.py @@ -58,8 +58,6 @@ `numpy.polynomial` """ -from __future__ import division, absolute_import, print_function - import warnings import numpy as np import numpy.linalg as la diff --git a/numpy/polynomial/laguerre.py b/numpy/polynomial/laguerre.py index 538a1d449786..bf8e116238d1 100644 --- a/numpy/polynomial/laguerre.py +++ b/numpy/polynomial/laguerre.py @@ -58,8 +58,6 @@ `numpy.polynomial` """ -from __future__ import division, absolute_import, print_function - import warnings import numpy as np import numpy.linalg as la diff --git a/numpy/polynomial/legendre.py b/numpy/polynomial/legendre.py index c11824761bb3..d74b87d5a0dd 100644 --- a/numpy/polynomial/legendre.py +++ b/numpy/polynomial/legendre.py @@ -81,8 +81,6 @@ numpy.polynomial.hermite_e """ -from __future__ import division, absolute_import, print_function - import warnings import numpy as np import numpy.linalg as la diff --git a/numpy/polynomial/polynomial.py b/numpy/polynomial/polynomial.py index 315ea1495883..92fdc06facbc 100644 --- a/numpy/polynomial/polynomial.py +++ b/numpy/polynomial/polynomial.py @@ -55,8 +55,6 @@ `numpy.polynomial` """ -from __future__ import division, absolute_import, print_function - __all__ = [ 'polyzero', 'polyone', 'polyx', 'polydomain', 'polyline', 'polyadd', 'polysub', 'polymulx', 'polymul', 'polydiv', 'polypow', 'polyval', diff --git a/numpy/polynomial/polyutils.py b/numpy/polynomial/polyutils.py index 5dcfa7a7a2ff..937e2cddde49 100644 --- a/numpy/polynomial/polyutils.py +++ b/numpy/polynomial/polyutils.py @@ -43,8 +43,6 @@ mapparms parameters of the linear map between domains. """ -from __future__ import division, absolute_import, print_function - import operator import functools import warnings diff --git a/numpy/polynomial/setup.py b/numpy/polynomial/setup.py index cb59ee1e56d9..8fc82cba1b3f 100644 --- a/numpy/polynomial/setup.py +++ b/numpy/polynomial/setup.py @@ -1,5 +1,3 @@ -from __future__ import division, print_function - def configuration(parent_package='',top_path=None): from numpy.distutils.misc_util import Configuration config = Configuration('polynomial', parent_package, top_path) diff --git a/numpy/polynomial/tests/test_chebyshev.py b/numpy/polynomial/tests/test_chebyshev.py index c8d2d6dbaae0..ce442563c779 100644 --- a/numpy/polynomial/tests/test_chebyshev.py +++ b/numpy/polynomial/tests/test_chebyshev.py @@ -1,8 +1,6 @@ """Tests for chebyshev module. """ -from __future__ import division, absolute_import, print_function - from functools import reduce import numpy as np diff --git a/numpy/polynomial/tests/test_classes.py b/numpy/polynomial/tests/test_classes.py index 2261f960b1d7..a9da64e22af7 100644 --- a/numpy/polynomial/tests/test_classes.py +++ b/numpy/polynomial/tests/test_classes.py @@ -3,8 +3,6 @@ This tests the convert and cast methods of all the polynomial classes. """ -from __future__ import division, absolute_import, print_function - import operator as op from numbers import Number diff --git a/numpy/polynomial/tests/test_hermite.py b/numpy/polynomial/tests/test_hermite.py index 271c1964b093..50175cdb3cad 100644 --- a/numpy/polynomial/tests/test_hermite.py +++ b/numpy/polynomial/tests/test_hermite.py @@ -1,8 +1,6 @@ """Tests for hermite module. """ -from __future__ import division, absolute_import, print_function - from functools import reduce import numpy as np diff --git a/numpy/polynomial/tests/test_hermite_e.py b/numpy/polynomial/tests/test_hermite_e.py index 434b30e7bb28..ec134d4072ee 100644 --- a/numpy/polynomial/tests/test_hermite_e.py +++ b/numpy/polynomial/tests/test_hermite_e.py @@ -1,8 +1,6 @@ """Tests for hermite_e module. """ -from __future__ import division, absolute_import, print_function - from functools import reduce import numpy as np diff --git a/numpy/polynomial/tests/test_laguerre.py b/numpy/polynomial/tests/test_laguerre.py index 4b9b2863757b..1f51d7ad7010 100644 --- a/numpy/polynomial/tests/test_laguerre.py +++ b/numpy/polynomial/tests/test_laguerre.py @@ -1,8 +1,6 @@ """Tests for laguerre module. """ -from __future__ import division, absolute_import, print_function - from functools import reduce import numpy as np diff --git a/numpy/polynomial/tests/test_legendre.py b/numpy/polynomial/tests/test_legendre.py index 917a7e03afdf..f48f4c645841 100644 --- a/numpy/polynomial/tests/test_legendre.py +++ b/numpy/polynomial/tests/test_legendre.py @@ -1,8 +1,6 @@ """Tests for legendre module. """ -from __future__ import division, absolute_import, print_function - from functools import reduce import numpy as np diff --git a/numpy/polynomial/tests/test_polynomial.py b/numpy/polynomial/tests/test_polynomial.py index 1436963c6715..a3d9817c09fd 100644 --- a/numpy/polynomial/tests/test_polynomial.py +++ b/numpy/polynomial/tests/test_polynomial.py @@ -1,8 +1,6 @@ """Tests for polynomial module. """ -from __future__ import division, absolute_import, print_function - from functools import reduce import numpy as np diff --git a/numpy/polynomial/tests/test_polyutils.py b/numpy/polynomial/tests/test_polyutils.py index 801c558ccca4..09a53d752a0f 100644 --- a/numpy/polynomial/tests/test_polyutils.py +++ b/numpy/polynomial/tests/test_polyutils.py @@ -1,8 +1,6 @@ """Tests for polyutils module. """ -from __future__ import division, absolute_import, print_function - import numpy as np import numpy.polynomial.polyutils as pu from numpy.testing import ( diff --git a/numpy/polynomial/tests/test_printing.py b/numpy/polynomial/tests/test_printing.py index 3f1236402228..1d0885de0499 100644 --- a/numpy/polynomial/tests/test_printing.py +++ b/numpy/polynomial/tests/test_printing.py @@ -1,5 +1,3 @@ -from __future__ import division, absolute_import, print_function - import numpy.polynomial as poly from numpy.testing import assert_equal diff --git a/numpy/random/__init__.py b/numpy/random/__init__.py index 1ceb5c4dd7b7..0b80999d844a 100644 --- a/numpy/random/__init__.py +++ b/numpy/random/__init__.py @@ -122,8 +122,6 @@ """ -from __future__ import division, absolute_import, print_function - __all__ = [ 'beta', 'binomial', diff --git a/numpy/random/setup.py b/numpy/random/setup.py index 1b093d6d381d..42c00ee5e8d1 100644 --- a/numpy/random/setup.py +++ b/numpy/random/setup.py @@ -1,5 +1,3 @@ -from __future__ import division, print_function - import os import platform import sys diff --git a/numpy/random/tests/test_random.py b/numpy/random/tests/test_random.py index 2e2ecedf894e..81d74650ef8e 100644 --- a/numpy/random/tests/test_random.py +++ b/numpy/random/tests/test_random.py @@ -1,4 +1,3 @@ -from __future__ import division, absolute_import, print_function import warnings import numpy as np diff --git a/numpy/random/tests/test_regression.py b/numpy/random/tests/test_regression.py index 509e2d57ff28..e70505cec96e 100644 --- a/numpy/random/tests/test_regression.py +++ b/numpy/random/tests/test_regression.py @@ -1,5 +1,3 @@ -from __future__ import division, absolute_import, print_function - import sys from numpy.testing import ( assert_, assert_array_equal, assert_raises, diff --git a/numpy/setup.py b/numpy/setup.py index 4ccdaeea5e94..742de2cae877 100644 --- a/numpy/setup.py +++ b/numpy/setup.py @@ -1,6 +1,4 @@ #!/usr/bin/env python -from __future__ import division, print_function - def configuration(parent_package='',top_path=None): from numpy.distutils.misc_util import Configuration diff --git a/numpy/testing/__init__.py b/numpy/testing/__init__.py index a8bd4fc1560c..e1f87621f9e7 100644 --- a/numpy/testing/__init__.py +++ b/numpy/testing/__init__.py @@ -5,8 +5,6 @@ away. """ -from __future__ import division, absolute_import, print_function - from unittest import TestCase from ._private.utils import * diff --git a/numpy/testing/_private/decorators.py b/numpy/testing/_private/decorators.py index 24c4e385d1d1..2012b80d320a 100644 --- a/numpy/testing/_private/decorators.py +++ b/numpy/testing/_private/decorators.py @@ -13,8 +13,6 @@ ``nose.tools`` for more information. """ -from __future__ import division, absolute_import, print_function - try: # Accessing collections abstract classes from collections # has been deprecated since Python 3.3 diff --git a/numpy/testing/_private/noseclasses.py b/numpy/testing/_private/noseclasses.py index e99bbc97de2d..7cad24620988 100644 --- a/numpy/testing/_private/noseclasses.py +++ b/numpy/testing/_private/noseclasses.py @@ -4,8 +4,6 @@ # Because this module imports nose directly, it should not # be used except by nosetester.py to avoid a general NumPy # dependency on nose. -from __future__ import division, absolute_import, print_function - import os import sys import doctest diff --git a/numpy/testing/_private/nosetester.py b/numpy/testing/_private/nosetester.py index 19569a5098a1..6226eeb3cca2 100644 --- a/numpy/testing/_private/nosetester.py +++ b/numpy/testing/_private/nosetester.py @@ -4,8 +4,6 @@ This module implements ``test()`` and ``bench()`` functions for NumPy modules. """ -from __future__ import division, absolute_import, print_function - import os import sys import warnings diff --git a/numpy/testing/_private/utils.py b/numpy/testing/_private/utils.py index a3bd6d7a50a3..1e118b538b7e 100644 --- a/numpy/testing/_private/utils.py +++ b/numpy/testing/_private/utils.py @@ -2,8 +2,6 @@ Utility function to facilitate testing. """ -from __future__ import division, absolute_import, print_function - import os import sys import platform diff --git a/numpy/testing/print_coercion_tables.py b/numpy/testing/print_coercion_tables.py index 72b22cee1ccd..c11b3196866a 100755 --- a/numpy/testing/print_coercion_tables.py +++ b/numpy/testing/print_coercion_tables.py @@ -2,8 +2,6 @@ """Prints type-coercion tables for the built-in NumPy types """ -from __future__ import division, absolute_import, print_function - import numpy as np # Generic object that can be added, but doesn't do anything else diff --git a/numpy/testing/setup.py b/numpy/testing/setup.py index 7c3f2fbdfd66..c061b688aca2 100755 --- a/numpy/testing/setup.py +++ b/numpy/testing/setup.py @@ -1,6 +1,4 @@ #!/usr/bin/env python -from __future__ import division, print_function - def configuration(parent_package='',top_path=None): from numpy.distutils.misc_util import Configuration diff --git a/numpy/testing/tests/test_decorators.py b/numpy/testing/tests/test_decorators.py index c029bf90c119..fc8d764c233e 100644 --- a/numpy/testing/tests/test_decorators.py +++ b/numpy/testing/tests/test_decorators.py @@ -2,8 +2,6 @@ Test the decorators from ``testing.decorators``. """ -from __future__ import division, absolute_import, print_function - import warnings import pytest diff --git a/numpy/testing/tests/test_doctesting.py b/numpy/testing/tests/test_doctesting.py index b77cd93e0b5c..92c2156d814a 100644 --- a/numpy/testing/tests/test_doctesting.py +++ b/numpy/testing/tests/test_doctesting.py @@ -1,8 +1,6 @@ """ Doctests for NumPy-specific nose/doctest modifications """ -from __future__ import division, absolute_import, print_function - #FIXME: None of these tests is run, because 'check' is not a recognized # testing prefix. diff --git a/numpy/testing/tests/test_utils.py b/numpy/testing/tests/test_utils.py index ad72b919983d..f752c63f3812 100644 --- a/numpy/testing/tests/test_utils.py +++ b/numpy/testing/tests/test_utils.py @@ -1,5 +1,3 @@ -from __future__ import division, absolute_import, print_function - import warnings import sys import os diff --git a/numpy/testing/utils.py b/numpy/testing/utils.py index 975f6ad5d1eb..753258c13683 100644 --- a/numpy/testing/utils.py +++ b/numpy/testing/utils.py @@ -3,8 +3,6 @@ set of tools """ -from __future__ import division, absolute_import, print_function - import warnings # 2018-04-04, numpy 1.15.0 ImportWarning diff --git a/numpy/tests/test_ctypeslib.py b/numpy/tests/test_ctypeslib.py index 521208c36d3d..5e19f06ce409 100644 --- a/numpy/tests/test_ctypeslib.py +++ b/numpy/tests/test_ctypeslib.py @@ -1,5 +1,3 @@ -from __future__ import division, absolute_import, print_function - import sys import pytest import weakref diff --git a/numpy/tests/test_matlib.py b/numpy/tests/test_matlib.py index 38a7e39dfb69..e04947a2e80f 100644 --- a/numpy/tests/test_matlib.py +++ b/numpy/tests/test_matlib.py @@ -1,5 +1,3 @@ -from __future__ import division, absolute_import, print_function - # As we are testing matrices, we ignore its PendingDeprecationWarnings try: import pytest diff --git a/numpy/tests/test_numpy_version.py b/numpy/tests/test_numpy_version.py index 7fac8fd22ead..916ab93830df 100644 --- a/numpy/tests/test_numpy_version.py +++ b/numpy/tests/test_numpy_version.py @@ -1,5 +1,3 @@ -from __future__ import division, absolute_import, print_function - import re import numpy as np diff --git a/numpy/tests/test_public_api.py b/numpy/tests/test_public_api.py index 0484bb8cdb45..9f5ae8a9268f 100644 --- a/numpy/tests/test_public_api.py +++ b/numpy/tests/test_public_api.py @@ -1,5 +1,3 @@ -from __future__ import division, absolute_import, print_function - import sys import subprocess import pkgutil diff --git a/numpy/tests/test_reloading.py b/numpy/tests/test_reloading.py index e378d1463f4b..2b5a324ba4d9 100644 --- a/numpy/tests/test_reloading.py +++ b/numpy/tests/test_reloading.py @@ -1,5 +1,3 @@ -from __future__ import division, absolute_import, print_function - import sys from numpy.testing import assert_raises, assert_, assert_equal diff --git a/numpy/tests/test_scripts.py b/numpy/tests/test_scripts.py index e42dc25f98e9..20447bcf358c 100644 --- a/numpy/tests/test_scripts.py +++ b/numpy/tests/test_scripts.py @@ -2,8 +2,6 @@ Test that we can run executable scripts that have been installed with numpy. """ -from __future__ import division, print_function, absolute_import - import sys import os import pytest diff --git a/numpy/tests/test_warnings.py b/numpy/tests/test_warnings.py index f5560a099a16..48896f4b7db4 100644 --- a/numpy/tests/test_warnings.py +++ b/numpy/tests/test_warnings.py @@ -2,8 +2,6 @@ Tests which scan for certain occurrences in the code, they may not find all of these occurrences but should catch almost all. """ -from __future__ import division, absolute_import, print_function - import sys import pytest diff --git a/pavement.py b/pavement.py index 352e375d23ec..494d8b79d433 100644 --- a/pavement.py +++ b/pavement.py @@ -22,8 +22,6 @@ - fix bdist_mpkg: we build the same source twice -> how to make sure we use the same underlying python for egg install in venv and for bdist_mpkg """ -from __future__ import division, print_function - import os import sys import shutil diff --git a/runtests.py b/runtests.py index a38054f86872..d36e5bd39a7e 100755 --- a/runtests.py +++ b/runtests.py @@ -29,8 +29,6 @@ $ python runtests.py --lcov-html """ -from __future__ import division, print_function - # # This is a generic test runner script for projects using NumPy's test # framework. Change the following values to adapt to your project: diff --git a/setup.py b/setup.py index 43f9521b5938..20bfc657c121 100755 --- a/setup.py +++ b/setup.py @@ -17,8 +17,6 @@ All NumPy wheels distributed on PyPI are BSD licensed. """ -from __future__ import division, print_function - DOCLINES = (__doc__ or '').split("\n") import os diff --git a/tools/allocation_tracking/setup.py b/tools/allocation_tracking/setup.py index a75c95e911e2..4462f9f4ec8c 100644 --- a/tools/allocation_tracking/setup.py +++ b/tools/allocation_tracking/setup.py @@ -1,5 +1,3 @@ -from __future__ import division, print_function - from distutils.core import setup from distutils.extension import Extension from Cython.Distutils import build_ext diff --git a/tools/allocation_tracking/track_allocations.py b/tools/allocation_tracking/track_allocations.py index d259938002f9..a997df64a577 100644 --- a/tools/allocation_tracking/track_allocations.py +++ b/tools/allocation_tracking/track_allocations.py @@ -1,5 +1,3 @@ -from __future__ import division, absolute_import, print_function - import numpy as np import gc import inspect diff --git a/tools/c_coverage/c_coverage_report.py b/tools/c_coverage/c_coverage_report.py index 327f6dc05b0e..28425054f4b5 100755 --- a/tools/c_coverage/c_coverage_report.py +++ b/tools/c_coverage/c_coverage_report.py @@ -4,8 +4,6 @@ valgrind's callgrind tool. """ -from __future__ import division, absolute_import, print_function - import optparse import os import re diff --git a/tools/changelog.py b/tools/changelog.py index b135b14e51cd..00ffdd9eb9f3 100755 --- a/tools/changelog.py +++ b/tools/changelog.py @@ -33,8 +33,6 @@ $ ./tools/announce $GITHUB v1.13.0..v1.14.0 > 1.14.0-changelog.rst """ -from __future__ import print_function, division - import os import sys import re diff --git a/tools/commitstats.py b/tools/commitstats.py index a35d7b724df6..14c37d4d2b97 100644 --- a/tools/commitstats.py +++ b/tools/commitstats.py @@ -1,5 +1,3 @@ -from __future__ import division, absolute_import, print_function - # Run svn log -l import re diff --git a/tools/cythonize.py b/tools/cythonize.py index e5352a9542b1..4d04906ea6e1 100755 --- a/tools/cythonize.py +++ b/tools/cythonize.py @@ -30,8 +30,6 @@ operates on the Cython .pyx files. """ -from __future__ import division, print_function, absolute_import - import os import re import sys diff --git a/tools/find_deprecated_escaped_characters.py b/tools/find_deprecated_escaped_characters.py index 6f90001ca6b1..401366bca638 100644 --- a/tools/find_deprecated_escaped_characters.py +++ b/tools/find_deprecated_escaped_characters.py @@ -7,8 +7,6 @@ be written as '\\(' or r'\('. """ -from __future__ import division, absolute_import, print_function - import sys def main(root): diff --git a/tools/npy_tempita/__init__.py b/tools/npy_tempita/__init__.py index f75f23a212d3..59f56809491b 100644 --- a/tools/npy_tempita/__init__.py +++ b/tools/npy_tempita/__init__.py @@ -32,8 +32,6 @@ def foo(bar): with a few changes to remove the six dependency. """ -from __future__ import absolute_import, division, print_function - import re import sys try: diff --git a/tools/npy_tempita/_looper.py b/tools/npy_tempita/_looper.py index 047bf52926aa..0135852e340b 100644 --- a/tools/npy_tempita/_looper.py +++ b/tools/npy_tempita/_looper.py @@ -17,8 +17,6 @@ 3 c """ -from __future__ import absolute_import, division, print_function - import sys from .compat3 import basestring_ diff --git a/tools/npy_tempita/compat3.py b/tools/npy_tempita/compat3.py index 01d7713455e0..d9d682ff55f5 100644 --- a/tools/npy_tempita/compat3.py +++ b/tools/npy_tempita/compat3.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import, division, print_function - import sys __all__ = ['PY3', 'b', 'basestring_', 'bytes', 'next', 'is_unicode', diff --git a/tools/openblas_support.py b/tools/openblas_support.py index 4a210cfe1c71..2c1b70d6f4a7 100644 --- a/tools/openblas_support.py +++ b/tools/openblas_support.py @@ -1,4 +1,3 @@ -from __future__ import division, absolute_import, print_function import os import sys import glob diff --git a/tools/refguide_check.py b/tools/refguide_check.py index ba045cebf71d..c647fb2ed9e4 100644 --- a/tools/refguide_check.py +++ b/tools/refguide_check.py @@ -25,8 +25,6 @@ $ python refguide_check.py --rst docs """ -from __future__ import print_function - import sys import os import re diff --git a/tools/swig/test/setup.py b/tools/swig/test/setup.py index 4ff870e19385..6bbfac2de25f 100755 --- a/tools/swig/test/setup.py +++ b/tools/swig/test/setup.py @@ -1,6 +1,4 @@ #! /usr/bin/env python -from __future__ import division, print_function - # System imports from distutils.core import * from distutils import sysconfig diff --git a/tools/swig/test/testArray.py b/tools/swig/test/testArray.py index 8d9c7977223b..c8d0d0edbf15 100755 --- a/tools/swig/test/testArray.py +++ b/tools/swig/test/testArray.py @@ -1,6 +1,4 @@ #! /usr/bin/env python -from __future__ import division, absolute_import, print_function - # System imports from distutils.util import get_platform import os diff --git a/tools/swig/test/testFarray.py b/tools/swig/test/testFarray.py index e8bf711c580d..67dace5b128c 100755 --- a/tools/swig/test/testFarray.py +++ b/tools/swig/test/testFarray.py @@ -1,6 +1,4 @@ #! /usr/bin/env python -from __future__ import division, absolute_import, print_function - # System imports from distutils.util import get_platform import os diff --git a/tools/swig/test/testFlat.py b/tools/swig/test/testFlat.py index 71be277b175b..470f157d88a2 100755 --- a/tools/swig/test/testFlat.py +++ b/tools/swig/test/testFlat.py @@ -1,6 +1,4 @@ #! /usr/bin/env python -from __future__ import division, absolute_import, print_function - # System imports from distutils.util import get_platform import os diff --git a/tools/swig/test/testFortran.py b/tools/swig/test/testFortran.py index 426e8943dec6..76bf1dd2a092 100644 --- a/tools/swig/test/testFortran.py +++ b/tools/swig/test/testFortran.py @@ -1,6 +1,4 @@ #! /usr/bin/env python -from __future__ import division, absolute_import, print_function - # System imports from distutils.util import get_platform import os diff --git a/tools/swig/test/testMatrix.py b/tools/swig/test/testMatrix.py index 065be0d443b2..24c64e281b9c 100755 --- a/tools/swig/test/testMatrix.py +++ b/tools/swig/test/testMatrix.py @@ -1,6 +1,4 @@ #! /usr/bin/env python -from __future__ import division, absolute_import, print_function - # System imports from distutils.util import get_platform import os diff --git a/tools/swig/test/testSuperTensor.py b/tools/swig/test/testSuperTensor.py index 97fe80c332a5..f6e15b6ace14 100644 --- a/tools/swig/test/testSuperTensor.py +++ b/tools/swig/test/testSuperTensor.py @@ -1,6 +1,4 @@ #! /usr/bin/env python -from __future__ import division, print_function - # System imports from distutils.util import get_platform from math import sqrt diff --git a/tools/swig/test/testTensor.py b/tools/swig/test/testTensor.py index ac1b7491a046..f8f492937756 100755 --- a/tools/swig/test/testTensor.py +++ b/tools/swig/test/testTensor.py @@ -1,6 +1,4 @@ #! /usr/bin/env python -from __future__ import division, absolute_import, print_function - # System imports from distutils.util import get_platform from math import sqrt diff --git a/tools/swig/test/testVector.py b/tools/swig/test/testVector.py index 45e763b360c1..e28bfcc1544f 100755 --- a/tools/swig/test/testVector.py +++ b/tools/swig/test/testVector.py @@ -1,6 +1,4 @@ #! /usr/bin/env python -from __future__ import division, absolute_import, print_function - # System imports from distutils.util import get_platform import os From e1aecb08f99321b72959cc50eb7b47454b613f52 Mon Sep 17 00:00:00 2001 From: Seth Troisi Date: Fri, 3 Jan 2020 13:23:52 -0800 Subject: [PATCH 0106/4713] MAINT: Remove Python2 specific C module setup (gh-15231) Dropping the support for python 2, the difference in module setup do not have to be accounted for anymore. This removes the macros and ifdef's related to module setup code and python 2 support. --- doc/Py3K.rst.txt | 2 ++ doc/source/user/c-info.ufunc-tutorial.rst | 16 -------------- .../code_generators/generate_numpy_api.py | 8 +------ .../code_generators/generate_ufunc_api.py | 8 +------ numpy/core/src/dummymodule.c | 9 -------- .../src/multiarray/_multiarray_tests.c.src | 17 ++------------- numpy/core/src/multiarray/arraytypes.c.src | 8 +++---- numpy/core/src/multiarray/compiled_base.c | 4 ++-- numpy/core/src/multiarray/descriptor.c | 6 +++--- numpy/core/src/multiarray/item_selection.c | 4 ++-- numpy/core/src/multiarray/multiarraymodule.c | 16 ++------------ .../core/src/umath/_operand_flag_tests.c.src | 18 ++-------------- numpy/core/src/umath/_rational_tests.c.src | 19 ++--------------- .../core/src/umath/_struct_ufunc_tests.c.src | 16 -------------- numpy/core/src/umath/_umath_tests.c.src | 18 +++------------- numpy/f2py/rules.py | 10 ++------- .../tests/src/array_from_pyobj/wrapmodule.c | 12 +---------- numpy/fft/_pocketfft.c | 21 ++----------------- numpy/linalg/lapack_litemodule.c | 18 ++-------------- numpy/linalg/umath_linalg.c.src | 19 +++-------------- 20 files changed, 36 insertions(+), 213 deletions(-) diff --git a/doc/Py3K.rst.txt b/doc/Py3K.rst.txt index b23536ca535c..3ff2f9c5d8eb 100644 --- a/doc/Py3K.rst.txt +++ b/doc/Py3K.rst.txt @@ -225,6 +225,8 @@ A #define in config.h, defined when building for Py3. Currently, this is generated as a part of the config. Is this sensible (we could also use Py_VERSION_HEX)? + This is being cleaned up in the C code. + private/npy_3kcompat.h ---------------------- diff --git a/doc/source/user/c-info.ufunc-tutorial.rst b/doc/source/user/c-info.ufunc-tutorial.rst index 96a73f9a60db..c5180d6a7bb6 100644 --- a/doc/source/user/c-info.ufunc-tutorial.rst +++ b/doc/source/user/c-info.ufunc-tutorial.rst @@ -976,7 +976,6 @@ The C file is given below. static void *data[1] = {NULL}; - #if defined(NPY_PY3K) static struct PyModuleDef moduledef = { PyModuleDef_HEAD_INIT, "struct_ufunc_test", @@ -988,31 +987,18 @@ The C file is given below. NULL, NULL }; - #endif - #if defined(NPY_PY3K) PyMODINIT_FUNC PyInit_struct_ufunc_test(void) - #else - PyMODINIT_FUNC initstruct_ufunc_test(void) - #endif { PyObject *m, *add_triplet, *d; PyObject *dtype_dict; PyArray_Descr *dtype; PyArray_Descr *dtypes[3]; - #if defined(NPY_PY3K) m = PyModule_Create(&moduledef); - #else - m = Py_InitModule("struct_ufunc_test", StructUfuncTestMethods); - #endif if (m == NULL) { - #if defined(NPY_PY3K) return NULL; - #else - return; - #endif } import_array(); @@ -1043,9 +1029,7 @@ The C file is given below. PyDict_SetItemString(d, "add_triplet", add_triplet); Py_DECREF(add_triplet); - #if defined(NPY_PY3K) return m; - #endif } .. index:: diff --git a/numpy/core/code_generators/generate_numpy_api.py b/numpy/core/code_generators/generate_numpy_api.py index 5e04fb86dd4f..efef9340f702 100644 --- a/numpy/core/code_generators/generate_numpy_api.py +++ b/numpy/core/code_generators/generate_numpy_api.py @@ -120,13 +120,7 @@ return 0; } -#if PY_VERSION_HEX >= 0x03000000 -#define NUMPY_IMPORT_ARRAY_RETVAL NULL -#else -#define NUMPY_IMPORT_ARRAY_RETVAL -#endif - -#define import_array() {if (_import_array() < 0) {PyErr_Print(); PyErr_SetString(PyExc_ImportError, "numpy.core.multiarray failed to import"); return NUMPY_IMPORT_ARRAY_RETVAL; } } +#define import_array() {if (_import_array() < 0) {PyErr_Print(); PyErr_SetString(PyExc_ImportError, "numpy.core.multiarray failed to import"); return NULL; } } #define import_array1(ret) {if (_import_array() < 0) {PyErr_Print(); PyErr_SetString(PyExc_ImportError, "numpy.core.multiarray failed to import"); return ret; } } diff --git a/numpy/core/code_generators/generate_ufunc_api.py b/numpy/core/code_generators/generate_ufunc_api.py index 1b0143e88be5..bcd37de57d0f 100644 --- a/numpy/core/code_generators/generate_ufunc_api.py +++ b/numpy/core/code_generators/generate_ufunc_api.py @@ -74,12 +74,6 @@ return 0; } -#if PY_VERSION_HEX >= 0x03000000 -#define NUMPY_IMPORT_UMATH_RETVAL NULL -#else -#define NUMPY_IMPORT_UMATH_RETVAL -#endif - #define import_umath() \ do {\ UFUNC_NOFPE\ @@ -87,7 +81,7 @@ PyErr_Print();\ PyErr_SetString(PyExc_ImportError,\ "numpy.core.umath failed to import");\ - return NUMPY_IMPORT_UMATH_RETVAL;\ + return NULL;\ }\ } while(0) diff --git a/numpy/core/src/dummymodule.c b/numpy/core/src/dummymodule.c index 718199f704a7..e26875736d23 100644 --- a/numpy/core/src/dummymodule.c +++ b/numpy/core/src/dummymodule.c @@ -16,7 +16,6 @@ static struct PyMethodDef methods[] = { }; -#if defined(NPY_PY3K) static struct PyModuleDef moduledef = { PyModuleDef_HEAD_INIT, "dummy", @@ -28,10 +27,8 @@ static struct PyModuleDef moduledef = { NULL, NULL }; -#endif /* Initialization function for the module */ -#if defined(NPY_PY3K) PyMODINIT_FUNC PyInit__dummy(void) { PyObject *m; m = PyModule_Create(&moduledef); @@ -40,9 +37,3 @@ PyMODINIT_FUNC PyInit__dummy(void) { } return m; } -#else -PyMODINIT_FUNC -init_dummy(void) { - Py_InitModule("_dummy", methods); -} -#endif diff --git a/numpy/core/src/multiarray/_multiarray_tests.c.src b/numpy/core/src/multiarray/_multiarray_tests.c.src index fa2efb428124..5e2cf0edd56b 100644 --- a/numpy/core/src/multiarray/_multiarray_tests.c.src +++ b/numpy/core/src/multiarray/_multiarray_tests.c.src @@ -2126,7 +2126,6 @@ static PyMethodDef Multiarray_TestsMethods[] = { }; -#if defined(NPY_PY3K) static struct PyModuleDef moduledef = { PyModuleDef_HEAD_INIT, "_multiarray_tests", @@ -2138,33 +2137,21 @@ static struct PyModuleDef moduledef = { NULL, NULL }; -#endif -#if defined(NPY_PY3K) -#define RETVAL m PyMODINIT_FUNC PyInit__multiarray_tests(void) -#else -#define RETVAL -PyMODINIT_FUNC -init_multiarray_tests(void) -#endif { PyObject *m; -#if defined(NPY_PY3K) m = PyModule_Create(&moduledef); -#else - m = Py_InitModule("_multiarray_tests", Multiarray_TestsMethods); -#endif if (m == NULL) { - return RETVAL; + return m; } import_array(); if (PyErr_Occurred()) { PyErr_SetString(PyExc_RuntimeError, "cannot load _multiarray_tests module."); } - return RETVAL; + return m; } NPY_NO_EXPORT int diff --git a/numpy/core/src/multiarray/arraytypes.c.src b/numpy/core/src/multiarray/arraytypes.c.src index 99897f9c2466..077fb0ec8b93 100644 --- a/numpy/core/src/multiarray/arraytypes.c.src +++ b/numpy/core/src/multiarray/arraytypes.c.src @@ -748,7 +748,7 @@ _setup_field(int i, PyArray_Descr *descr, PyArrayObject *arr, } ((PyArrayObject_fields *)(arr))->descr = new; - if ((new->alignment > 1) && + if ((new->alignment > 1) && ((((uintptr_t)dstdata + offset) % new->alignment) != 0)) { PyArray_CLEARFLAGS(arr, NPY_ARRAY_ALIGNED); } @@ -836,7 +836,7 @@ VOID_setitem(PyObject *op, void *input, void *vap) if (names_size != PyTuple_Size(op)) { errmsg = PyUString_FromFormat( "could not assign tuple of length %zd to structure " - "with %" NPY_INTP_FMT " fields.", + "with %" NPY_INTP_FMT " fields.", PyTuple_Size(op), names_size); PyErr_SetObject(PyExc_ValueError, errmsg); Py_DECREF(errmsg); @@ -3000,7 +3000,7 @@ OBJECT_compare(PyObject **ip1, PyObject **ip2, PyArrayObject *NPY_UNUSED(ap)) ret = PyObject_RichCompareBool(*ip1, *ip2, Py_LT); if (ret < 0) { - /* error occurred, avoid the next call to PyObject_RichCompareBool */ + /* error occurred, avoid the next call to PyObject_RichCompareBool */ return 0; } if (ret == 1) { @@ -4429,7 +4429,7 @@ static PyArray_ArrFuncs _Py@NAME@_ArrFuncs = { #if @rsort@ aradixsort_@suff@ #else - atimsort_@suff@ + atimsort_@suff@ #endif }, #else diff --git a/numpy/core/src/multiarray/compiled_base.c b/numpy/core/src/multiarray/compiled_base.c index 055d3e60f0b3..cc37026b0db4 100644 --- a/numpy/core/src/multiarray/compiled_base.c +++ b/numpy/core/src/multiarray/compiled_base.c @@ -1159,7 +1159,7 @@ arr_ravel_multi_index(PyObject *self, PyObject *args, PyObject *kwds) } -/* +/* * Inner loop for unravel_index * order must be NPY_CORDER or NPY_FORTRANORDER */ @@ -1186,7 +1186,7 @@ unravel_index_loop(int unravel_ndim, npy_intp *unravel_dims, } idx = idx_start; for (i = 0; i < unravel_ndim; ++i) { - /* + /* * Using a local seems to enable single-divide optimization * but only if the / precedes the % */ diff --git a/numpy/core/src/multiarray/descriptor.c b/numpy/core/src/multiarray/descriptor.c index d4e18e4579ff..89934bbd46c7 100644 --- a/numpy/core/src/multiarray/descriptor.c +++ b/numpy/core/src/multiarray/descriptor.c @@ -241,7 +241,7 @@ _convert_from_tuple(PyObject *obj, int align) if (!PyArray_DescrConverter(PyTuple_GET_ITEM(obj, 0), &type)) { return NULL; } - } + } val = PyTuple_GET_ITEM(obj,1); /* try to interpret next item as a type */ res = _use_inherit(type, val, &errflag); @@ -455,11 +455,11 @@ _convert_from_array_descr(PyObject *obj, int align) Py_INCREF(name); #if !defined(NPY_PY3K) - /* convert unicode name to ascii on Python 2 if possible */ + /* convert unicode name to ascii on Python 2 if possible */ if (PyUnicode_Check(name)) { PyObject *tmp = PyUnicode_AsASCIIString(name); Py_DECREF(name); - if (tmp == NULL) { + if (tmp == NULL) { goto fail; } name = tmp; diff --git a/numpy/core/src/multiarray/item_selection.c b/numpy/core/src/multiarray/item_selection.c index a6ac902d306f..e6867083f9aa 100644 --- a/numpy/core/src/multiarray/item_selection.c +++ b/numpy/core/src/multiarray/item_selection.c @@ -2392,7 +2392,7 @@ PyArray_Nonzero(PyArrayObject *self) Py_DECREF(ret); return NULL; } - + needs_api = NpyIter_IterationNeedsAPI(iter); NPY_BEGIN_THREADS_NDITER(iter); @@ -2436,7 +2436,7 @@ PyArray_Nonzero(PyArrayObject *self) Py_DECREF(ret); return NULL; } - + /* if executed `nonzero()` check for miscount due to side-effect */ if (!is_bool && added_count != nonzero_count) { PyErr_SetString(PyExc_RuntimeError, diff --git a/numpy/core/src/multiarray/multiarraymodule.c b/numpy/core/src/multiarray/multiarraymodule.c index 33b654729fa0..eb593bdb5741 100644 --- a/numpy/core/src/multiarray/multiarraymodule.c +++ b/numpy/core/src/multiarray/multiarraymodule.c @@ -4551,7 +4551,6 @@ intern_strings(void) npy_ma_str_ndmin && npy_ma_str_axis1 && npy_ma_str_axis2; } -#if defined(NPY_PY3K) static struct PyModuleDef moduledef = { PyModuleDef_HEAD_INIT, "_multiarray_umath", @@ -4563,25 +4562,14 @@ static struct PyModuleDef moduledef = { NULL, NULL }; -#endif /* Initialization function for the module */ -#if defined(NPY_PY3K) -#define RETVAL(x) x PyMODINIT_FUNC PyInit__multiarray_umath(void) { -#else -#define RETVAL(x) -PyMODINIT_FUNC init_multiarray_umath(void) { -#endif PyObject *m, *d, *s; PyObject *c_api; /* Create the module and add the functions */ -#if defined(NPY_PY3K) m = PyModule_Create(&moduledef); -#else - m = Py_InitModule("_multiarray_umath", array_module_methods); -#endif if (!m) { goto err; } @@ -4766,12 +4754,12 @@ PyMODINIT_FUNC init_multiarray_umath(void) { if (initumath(m) != 0) { goto err; } - return RETVAL(m); + return m; err: if (!PyErr_Occurred()) { PyErr_SetString(PyExc_RuntimeError, "cannot load multiarray module."); } - return RETVAL(NULL); + return NULL; } diff --git a/numpy/core/src/umath/_operand_flag_tests.c.src b/numpy/core/src/umath/_operand_flag_tests.c.src index 551a9c6329b7..15fd7be6af0b 100644 --- a/numpy/core/src/umath/_operand_flag_tests.c.src +++ b/numpy/core/src/umath/_operand_flag_tests.c.src @@ -39,7 +39,6 @@ static char types[2] = {NPY_LONG, NPY_LONG}; static void *data[1] = {NULL}; -#if defined(NPY_PY3K) static struct PyModuleDef moduledef = { PyModuleDef_HEAD_INIT, "_operand_flag_tests", @@ -52,22 +51,12 @@ static struct PyModuleDef moduledef = { NULL }; -#define RETVAL m PyMODINIT_FUNC PyInit__operand_flag_tests(void) { -#else -#define RETVAL -PyMODINIT_FUNC init_operand_flag_tests(void) -{ -#endif PyObject *m = NULL; PyObject *ufunc; -#if defined(NPY_PY3K) m = PyModule_Create(&moduledef); -#else - m = Py_InitModule("_operand_flag_tests", TestMethods); -#endif if (m == NULL) { goto fail; } @@ -87,19 +76,16 @@ PyMODINIT_FUNC init_operand_flag_tests(void) ((PyUFuncObject*)ufunc)->iter_flags = NPY_ITER_REDUCE_OK; PyModule_AddObject(m, "inplace_add", (PyObject*)ufunc); - return RETVAL; + return m; fail: if (!PyErr_Occurred()) { PyErr_SetString(PyExc_RuntimeError, "cannot load _operand_flag_tests module."); } -#if defined(NPY_PY3K) if (m) { Py_DECREF(m); m = NULL; } -#endif - return RETVAL; - + return m; } diff --git a/numpy/core/src/umath/_rational_tests.c.src b/numpy/core/src/umath/_rational_tests.c.src index 615e395c7486..17fffdae2f79 100644 --- a/numpy/core/src/umath/_rational_tests.c.src +++ b/numpy/core/src/umath/_rational_tests.c.src @@ -1126,7 +1126,6 @@ PyMethodDef module_methods[] = { {0} /* sentinel */ }; -#if defined(NPY_PY3K) static struct PyModuleDef moduledef = { PyModuleDef_HEAD_INIT, "_rational_tests", @@ -1138,16 +1137,8 @@ static struct PyModuleDef moduledef = { NULL, NULL }; -#endif -#if defined(NPY_PY3K) -#define RETVAL m PyMODINIT_FUNC PyInit__rational_tests(void) { -#else -#define RETVAL -PyMODINIT_FUNC init_rational_tests(void) { -#endif - PyObject *m = NULL; PyObject* numpy_str; PyObject* numpy; @@ -1292,11 +1283,7 @@ PyMODINIT_FUNC init_rational_tests(void) { REGISTER_UFUNC_UNARY(sign) /* Create module */ -#if defined(NPY_PY3K) m = PyModule_Create(&moduledef); -#else - m = Py_InitModule("_rational_tests", module_methods); -#endif if (!m) { goto fail; @@ -1392,18 +1379,16 @@ PyMODINIT_FUNC init_rational_tests(void) { GCD_LCM_UFUNC(gcd,NPY_INT64,"greatest common denominator of two integers"); GCD_LCM_UFUNC(lcm,NPY_INT64,"least common multiple of two integers"); - return RETVAL; + return m; fail: if (!PyErr_Occurred()) { PyErr_SetString(PyExc_RuntimeError, "cannot load _rational_tests module."); } -#if defined(NPY_PY3K) if (m) { Py_DECREF(m); m = NULL; } -#endif - return RETVAL; + return m; } diff --git a/numpy/core/src/umath/_struct_ufunc_tests.c.src b/numpy/core/src/umath/_struct_ufunc_tests.c.src index 3eaac73e1d8d..1706dc829cea 100644 --- a/numpy/core/src/umath/_struct_ufunc_tests.c.src +++ b/numpy/core/src/umath/_struct_ufunc_tests.c.src @@ -100,7 +100,6 @@ static PyMethodDef StructUfuncTestMethods[] = { {NULL, NULL, 0, NULL} }; -#if defined(NPY_PY3K) static struct PyModuleDef moduledef = { PyModuleDef_HEAD_INIT, "_struct_ufunc_tests", @@ -112,31 +111,18 @@ static struct PyModuleDef moduledef = { NULL, NULL }; -#endif -#if defined(NPY_PY3K) PyMODINIT_FUNC PyInit__struct_ufunc_tests(void) -#else -PyMODINIT_FUNC init_struct_ufunc_tests(void) -#endif { PyObject *m, *add_triplet, *d; PyObject *dtype_dict; PyArray_Descr *dtype; PyArray_Descr *dtypes[3]; -#if defined(NPY_PY3K) m = PyModule_Create(&moduledef); -#else - m = Py_InitModule("_struct_ufunc_tests", StructUfuncTestMethods); -#endif if (m == NULL) { -#if defined(NPY_PY3K) return NULL; -#else - return; -#endif } import_array(); @@ -166,7 +152,5 @@ PyMODINIT_FUNC init_struct_ufunc_tests(void) PyDict_SetItemString(d, "add_triplet", add_triplet); Py_DECREF(add_triplet); -#if defined(NPY_PY3K) return m; -#endif } diff --git a/numpy/core/src/umath/_umath_tests.c.src b/numpy/core/src/umath/_umath_tests.c.src index 6c3bcce7133a..bd3fe80b6596 100644 --- a/numpy/core/src/umath/_umath_tests.c.src +++ b/numpy/core/src/umath/_umath_tests.c.src @@ -586,7 +586,6 @@ static PyMethodDef UMath_TestsMethods[] = { {NULL, NULL, 0, NULL} /* Sentinel */ }; -#if defined(NPY_PY3K) static struct PyModuleDef moduledef = { PyModuleDef_HEAD_INIT, "_umath_tests", @@ -598,27 +597,16 @@ static struct PyModuleDef moduledef = { NULL, NULL }; -#endif /* Initialization function for the module */ -#if defined(NPY_PY3K) -#define RETVAL(x) x PyMODINIT_FUNC PyInit__umath_tests(void) { -#else -#define RETVAL(x) -PyMODINIT_FUNC init_umath_tests(void) { -#endif PyObject *m; PyObject *d; PyObject *version; -#if defined(NPY_PY3K) m = PyModule_Create(&moduledef); -#else - m = Py_InitModule("_umath_tests", UMath_TestsMethods); -#endif if (m == NULL) { - return RETVAL(NULL); + return NULL; } import_array(); @@ -636,8 +624,8 @@ PyMODINIT_FUNC init_umath_tests(void) { PyErr_Print(); PyErr_SetString(PyExc_RuntimeError, "cannot load _umath_tests module."); - return RETVAL(NULL); + return NULL; } - return RETVAL(m); + return m; } diff --git a/numpy/f2py/rules.py b/numpy/f2py/rules.py index 28eb9da30871..a147f94b4db8 100755 --- a/numpy/f2py/rules.py +++ b/numpy/f2py/rules.py @@ -194,13 +194,7 @@ }; #endif -#if PY_VERSION_HEX >= 0x03000000 -#define RETVAL m PyMODINIT_FUNC PyInit_#modulename#(void) { -#else -#define RETVAL -PyMODINIT_FUNC init#modulename#(void) { -#endif \tint i; \tPyObject *m,*d, *s, *tmp; #if PY_VERSION_HEX >= 0x03000000 @@ -211,7 +205,7 @@ \tPy_TYPE(&PyFortran_Type) = &PyType_Type; \timport_array(); \tif (PyErr_Occurred()) -\t\t{PyErr_SetString(PyExc_ImportError, \"can't initialize module #modulename# (failed to import numpy)\"); return RETVAL;} +\t\t{PyErr_SetString(PyExc_ImportError, \"can't initialize module #modulename# (failed to import numpy)\"); return m;} \td = PyModule_GetDict(m); \ts = PyString_FromString(\"$R""" + """evision: $\"); \tPyDict_SetItemString(d, \"__version__\", s); @@ -245,7 +239,7 @@ \tif (! PyErr_Occurred()) \t\ton_exit(f2py_report_on_exit,(void*)\"#modulename#\"); #endif -\treturn RETVAL; +\treturn m; } #ifdef __cplusplus } diff --git a/numpy/f2py/tests/src/array_from_pyobj/wrapmodule.c b/numpy/f2py/tests/src/array_from_pyobj/wrapmodule.c index 978db4e6902a..369221c75d26 100644 --- a/numpy/f2py/tests/src/array_from_pyobj/wrapmodule.c +++ b/numpy/f2py/tests/src/array_from_pyobj/wrapmodule.c @@ -143,19 +143,9 @@ static struct PyModuleDef moduledef = { }; #endif -#if PY_VERSION_HEX >= 0x03000000 -#define RETVAL m PyMODINIT_FUNC PyInit_test_array_from_pyobj_ext(void) { -#else -#define RETVAL -PyMODINIT_FUNC inittest_array_from_pyobj_ext(void) { -#endif PyObject *m,*d, *s; -#if PY_VERSION_HEX >= 0x03000000 m = wrap_module = PyModule_Create(&moduledef); -#else - m = wrap_module = Py_InitModule("test_array_from_pyobj_ext", f2py_module_methods); -#endif Py_TYPE(&PyFortran_Type) = &PyType_Type; import_array(); if (PyErr_Occurred()) @@ -238,7 +228,7 @@ PyMODINIT_FUNC inittest_array_from_pyobj_ext(void) { on_exit(f2py_report_on_exit,(void*)"array_from_pyobj.wrap.call"); #endif - return RETVAL; + return m; } #ifdef __cplusplus } diff --git a/numpy/fft/_pocketfft.c b/numpy/fft/_pocketfft.c index d75b9983c64b..de86e36d356a 100644 --- a/numpy/fft/_pocketfft.c +++ b/numpy/fft/_pocketfft.c @@ -2359,7 +2359,6 @@ static struct PyMethodDef methods[] = { {NULL, NULL, 0, NULL} /* sentinel */ }; -#if PY_MAJOR_VERSION >= 3 static struct PyModuleDef moduledef = { PyModuleDef_HEAD_INIT, "_pocketfft_internal", @@ -2371,30 +2370,14 @@ static struct PyModuleDef moduledef = { NULL, NULL }; -#endif /* Initialization function for the module */ -#if PY_MAJOR_VERSION >= 3 -#define RETVAL(x) x PyMODINIT_FUNC PyInit__pocketfft_internal(void) -#else -#define RETVAL(x) -PyMODINIT_FUNC -init_pocketfft_internal(void) -#endif { PyObject *m; -#if PY_MAJOR_VERSION >= 3 m = PyModule_Create(&moduledef); -#else - static const char module_documentation[] = ""; - - m = Py_InitModule4("_pocketfft_internal", methods, - module_documentation, - (PyObject*)NULL,PYTHON_API_VERSION); -#endif if (m == NULL) { - return RETVAL(NULL); + return NULL; } /* Import the array object */ @@ -2402,5 +2385,5 @@ init_pocketfft_internal(void) /* XXXX Add constants here */ - return RETVAL(m); + return m; } diff --git a/numpy/linalg/lapack_litemodule.c b/numpy/linalg/lapack_litemodule.c index 56f38364f393..362a593a61b9 100644 --- a/numpy/linalg/lapack_litemodule.c +++ b/numpy/linalg/lapack_litemodule.c @@ -377,7 +377,6 @@ static struct PyMethodDef lapack_lite_module_methods[] = { }; -#if PY_MAJOR_VERSION >= 3 static struct PyModuleDef moduledef = { PyModuleDef_HEAD_INIT, "lapack_lite", @@ -389,27 +388,14 @@ static struct PyModuleDef moduledef = { NULL, NULL }; -#endif /* Initialization function for the module */ -#if PY_MAJOR_VERSION >= 3 -#define RETVAL(x) x PyMODINIT_FUNC PyInit_lapack_lite(void) -#else -#define RETVAL(x) -PyMODINIT_FUNC -initlapack_lite(void) -#endif { PyObject *m,*d; -#if PY_MAJOR_VERSION >= 3 m = PyModule_Create(&moduledef); -#else - m = Py_InitModule4("lapack_lite", lapack_lite_module_methods, - "", (PyObject*)NULL,PYTHON_API_VERSION); -#endif if (m == NULL) { - return RETVAL(NULL); + return NULL; } import_array(); d = PyModule_GetDict(m); @@ -422,5 +408,5 @@ initlapack_lite(void) PyDict_SetItemString(d, "_ilp64", Py_False); #endif - return RETVAL(m); + return m; } diff --git a/numpy/linalg/umath_linalg.c.src b/numpy/linalg/umath_linalg.c.src index e864c541b089..00ff6b7a82a6 100644 --- a/numpy/linalg/umath_linalg.c.src +++ b/numpy/linalg/umath_linalg.c.src @@ -3626,7 +3626,6 @@ static PyMethodDef UMath_LinAlgMethods[] = { {NULL, NULL, 0, NULL} /* Sentinel */ }; -#if defined(NPY_PY3K) static struct PyModuleDef moduledef = { PyModuleDef_HEAD_INIT, UMATH_LINALG_MODULE_NAME, @@ -3638,29 +3637,17 @@ static struct PyModuleDef moduledef = { NULL, NULL }; -#endif -#if defined(NPY_PY3K) -#define RETVAL(x) x PyObject *PyInit__umath_linalg(void) -#else -#define RETVAL(x) -PyMODINIT_FUNC -init_umath_linalg(void) -#endif { PyObject *m; PyObject *d; PyObject *version; init_constants(); -#if defined(NPY_PY3K) m = PyModule_Create(&moduledef); -#else - m = Py_InitModule(UMATH_LINALG_MODULE_NAME, UMath_LinAlgMethods); -#endif if (m == NULL) { - return RETVAL(NULL); + return NULL; } import_array(); @@ -3678,8 +3665,8 @@ init_umath_linalg(void) if (PyErr_Occurred()) { PyErr_SetString(PyExc_RuntimeError, "cannot load _umath_linalg module."); - return RETVAL(NULL); + return NULL; } - return RETVAL(m); + return m; } From 24189be60ec4d823f4068be727b5d28f7eacc823 Mon Sep 17 00:00:00 2001 From: Seth Troisi Date: Fri, 3 Jan 2020 13:44:22 -0800 Subject: [PATCH 0107/4713] Cleaning up PY_MAJOR_VERSION/PY_VERSION_HEX --- doc/Py3K.rst.txt | 2 - doc/source/user/c-info.ufunc-tutorial.rst | 87 ------------------- .../code_generators/generate_numpy_api.py | 9 -- .../code_generators/generate_ufunc_api.py | 9 -- numpy/core/include/numpy/ndarrayobject.h | 17 ---- .../include/numpy/npy_1_7_deprecated_api.h | 7 -- numpy/core/include/numpy/npy_3kcompat.h | 2 - numpy/core/src/multiarray/scalartypes.c.src | 12 --- numpy/core/src/multiarray/scalartypes.h | 5 -- numpy/core/src/umath/_rational_tests.c.src | 17 ---- numpy/core/src/umath/ufunc_object.c | 22 ----- numpy/f2py/cfuncs.py | 16 ---- numpy/f2py/rules.py | 18 ---- numpy/f2py/src/fortranobject.c | 36 -------- numpy/f2py/src/fortranobject.h | 10 --- .../tests/src/array_from_pyobj/wrapmodule.c | 2 - tools/swig/numpy.i | 7 +- tools/swig/pyfragments.swg | 15 ---- 18 files changed, 1 insertion(+), 292 deletions(-) diff --git a/doc/Py3K.rst.txt b/doc/Py3K.rst.txt index 3ff2f9c5d8eb..395a2096260e 100644 --- a/doc/Py3K.rst.txt +++ b/doc/Py3K.rst.txt @@ -357,9 +357,7 @@ The Py2/Py3 compatible structure definition looks like:: (binaryfunc)0, /*nb_true_divide*/ 0, /*nb_inplace_floor_divide*/ 0, /*nb_inplace_true_divide*/ - #if PY_VERSION_HEX >= 0x02050000 (unaryfunc)NULL, /*nb_index*/ - #endif }; diff --git a/doc/source/user/c-info.ufunc-tutorial.rst b/doc/source/user/c-info.ufunc-tutorial.rst index c5180d6a7bb6..8ff45a934daa 100644 --- a/doc/source/user/c-info.ufunc-tutorial.rst +++ b/doc/source/user/c-info.ufunc-tutorial.rst @@ -137,7 +137,6 @@ the module. /* This initiates the module using the above definitions. */ - #if PY_VERSION_HEX >= 0x03000000 static struct PyModuleDef moduledef = { PyModuleDef_HEAD_INIT, "spam", @@ -159,17 +158,6 @@ the module. } return m; } - #else - PyMODINIT_FUNC initspam(void) - { - PyObject *m; - - m = Py_InitModule("spam", SpamMethods); - if (m == NULL) { - return; - } - } - #endif To use the setup.py file, place setup.py and spammodule.c in the same folder. Then python setup.py build will build the module to import, @@ -322,7 +310,6 @@ the primary thing that must be changed to create your own ufunc. static void *data[1] = {NULL}; - #if PY_VERSION_HEX >= 0x03000000 static struct PyModuleDef moduledef = { PyModuleDef_HEAD_INIT, "npufunc", @@ -357,30 +344,6 @@ the primary thing that must be changed to create your own ufunc. return m; } - #else - PyMODINIT_FUNC initnpufunc(void) - { - PyObject *m, *logit, *d; - - - m = Py_InitModule("npufunc", LogitMethods); - if (m == NULL) { - return; - } - - import_array(); - import_umath(); - - logit = PyUFunc_FromFuncAndData(funcs, data, types, 1, 1, 1, - PyUFunc_None, "logit", - "logit_docstring", 0); - - d = PyModule_GetDict(m); - - PyDict_SetItemString(d, "logit", logit); - Py_DECREF(logit); - } - #endif This is a setup.py file for the above code. As before, the module can be build via calling python setup.py build at the command prompt, @@ -601,7 +564,6 @@ the primary thing that must be changed to create your own ufunc. NPY_LONGDOUBLE, NPY_LONGDOUBLE}; static void *data[4] = {NULL, NULL, NULL, NULL}; - #if PY_VERSION_HEX >= 0x03000000 static struct PyModuleDef moduledef = { PyModuleDef_HEAD_INIT, "npufunc", @@ -636,30 +598,6 @@ the primary thing that must be changed to create your own ufunc. return m; } - #else - PyMODINIT_FUNC initnpufunc(void) - { - PyObject *m, *logit, *d; - - - m = Py_InitModule("npufunc", LogitMethods); - if (m == NULL) { - return; - } - - import_array(); - import_umath(); - - logit = PyUFunc_FromFuncAndData(funcs, data, types, 4, 1, 1, - PyUFunc_None, "logit", - "logit_docstring", 0); - - d = PyModule_GetDict(m); - - PyDict_SetItemString(d, "logit", logit); - Py_DECREF(logit); - } - #endif This is a setup.py file for the above code. As before, the module can be build via calling python setup.py build at the command prompt, @@ -824,7 +762,6 @@ as well as all other properties of a ufunc. static void *data[1] = {NULL}; - #if PY_VERSION_HEX >= 0x03000000 static struct PyModuleDef moduledef = { PyModuleDef_HEAD_INIT, "npufunc", @@ -859,30 +796,6 @@ as well as all other properties of a ufunc. return m; } - #else - PyMODINIT_FUNC initnpufunc(void) - { - PyObject *m, *logit, *d; - - - m = Py_InitModule("npufunc", LogitMethods); - if (m == NULL) { - return; - } - - import_array(); - import_umath(); - - logit = PyUFunc_FromFuncAndData(funcs, data, types, 1, 2, 2, - PyUFunc_None, "logit", - "logit_docstring", 0); - - d = PyModule_GetDict(m); - - PyDict_SetItemString(d, "logit", logit); - Py_DECREF(logit); - } - #endif .. _`sec:NumPy-struct-dtype`: diff --git a/numpy/core/code_generators/generate_numpy_api.py b/numpy/core/code_generators/generate_numpy_api.py index efef9340f702..754b4b3ceec3 100644 --- a/numpy/core/code_generators/generate_numpy_api.py +++ b/numpy/core/code_generators/generate_numpy_api.py @@ -59,21 +59,12 @@ return -1; } -#if PY_VERSION_HEX >= 0x03000000 if (!PyCapsule_CheckExact(c_api)) { PyErr_SetString(PyExc_RuntimeError, "_ARRAY_API is not PyCapsule object"); Py_DECREF(c_api); return -1; } PyArray_API = (void **)PyCapsule_GetPointer(c_api, NULL); -#else - if (!PyCObject_Check(c_api)) { - PyErr_SetString(PyExc_RuntimeError, "_ARRAY_API is not PyCObject object"); - Py_DECREF(c_api); - return -1; - } - PyArray_API = (void **)PyCObject_AsVoidPtr(c_api); -#endif Py_DECREF(c_api); if (PyArray_API == NULL) { PyErr_SetString(PyExc_RuntimeError, "_ARRAY_API is NULL pointer"); diff --git a/numpy/core/code_generators/generate_ufunc_api.py b/numpy/core/code_generators/generate_ufunc_api.py index bcd37de57d0f..72ceadc0ec37 100644 --- a/numpy/core/code_generators/generate_ufunc_api.py +++ b/numpy/core/code_generators/generate_ufunc_api.py @@ -51,21 +51,12 @@ return -1; } -#if PY_VERSION_HEX >= 0x03000000 if (!PyCapsule_CheckExact(c_api)) { PyErr_SetString(PyExc_RuntimeError, "_UFUNC_API is not PyCapsule object"); Py_DECREF(c_api); return -1; } PyUFunc_API = (void **)PyCapsule_GetPointer(c_api, NULL); -#else - if (!PyCObject_Check(c_api)) { - PyErr_SetString(PyExc_RuntimeError, "_UFUNC_API is not PyCObject object"); - Py_DECREF(c_api); - return -1; - } - PyUFunc_API = (void **)PyCObject_AsVoidPtr(c_api); -#endif Py_DECREF(c_api); if (PyUFunc_API == NULL) { PyErr_SetString(PyExc_RuntimeError, "_UFUNC_API is NULL pointer"); diff --git a/numpy/core/include/numpy/ndarrayobject.h b/numpy/core/include/numpy/ndarrayobject.h index 95e9cb0603bb..b18d75f35ad7 100644 --- a/numpy/core/include/numpy/ndarrayobject.h +++ b/numpy/core/include/numpy/ndarrayobject.h @@ -45,7 +45,6 @@ extern "C" { #define PyArray_CheckScalar(m) (PyArray_IsScalar(m, Generic) || \ PyArray_IsZeroDim(m)) -#if PY_MAJOR_VERSION >= 3 #define PyArray_IsPythonNumber(obj) \ (PyFloat_Check(obj) || PyComplex_Check(obj) || \ PyLong_Check(obj) || PyBool_Check(obj)) @@ -54,17 +53,6 @@ extern "C" { #define PyArray_IsPythonScalar(obj) \ (PyArray_IsPythonNumber(obj) || PyBytes_Check(obj) || \ PyUnicode_Check(obj)) -#else -#define PyArray_IsPythonNumber(obj) \ - (PyInt_Check(obj) || PyFloat_Check(obj) || PyComplex_Check(obj) || \ - PyLong_Check(obj) || PyBool_Check(obj)) -#define PyArray_IsIntegerScalar(obj) (PyInt_Check(obj) \ - || PyLong_Check(obj) \ - || PyArray_IsScalar((obj), Integer)) -#define PyArray_IsPythonScalar(obj) \ - (PyArray_IsPythonNumber(obj) || PyString_Check(obj) || \ - PyUnicode_Check(obj)) -#endif #define PyArray_IsAnyScalar(obj) \ (PyArray_IsScalar(obj, Generic) || PyArray_IsPythonScalar(obj)) @@ -248,11 +236,6 @@ NPY_TITLE_KEY_check(PyObject *key, PyObject *value) if (PyUnicode_Check(title) && PyUnicode_Check(key)) { return PyUnicode_Compare(title, key) == 0 ? 1 : 0; } -#if PY_VERSION_HEX < 0x03000000 - if (PyString_Check(title) && PyString_Check(key)) { - return PyObject_Compare(title, key) == 0 ? 1 : 0; - } -#endif #endif return 0; } diff --git a/numpy/core/include/numpy/npy_1_7_deprecated_api.h b/numpy/core/include/numpy/npy_1_7_deprecated_api.h index a6ee21219cc7..4404580102a1 100644 --- a/numpy/core/include/numpy/npy_1_7_deprecated_api.h +++ b/numpy/core/include/numpy/npy_1_7_deprecated_api.h @@ -69,18 +69,11 @@ #define PyArray_DEFAULT NPY_DEFAULT_TYPE /* These DATETIME bits aren't used internally */ -#if PY_VERSION_HEX >= 0x03000000 #define PyDataType_GetDatetimeMetaData(descr) \ ((descr->metadata == NULL) ? NULL : \ ((PyArray_DatetimeMetaData *)(PyCapsule_GetPointer( \ PyDict_GetItemString( \ descr->metadata, NPY_METADATA_DTSTR), NULL)))) -#else -#define PyDataType_GetDatetimeMetaData(descr) \ - ((descr->metadata == NULL) ? NULL : \ - ((PyArray_DatetimeMetaData *)(PyCObject_AsVoidPtr( \ - PyDict_GetItemString(descr->metadata, NPY_METADATA_DTSTR))))) -#endif /* * Deprecated as of NumPy 1.7, this kind of shortcut doesn't diff --git a/numpy/core/include/numpy/npy_3kcompat.h b/numpy/core/include/numpy/npy_3kcompat.h index 7ed263796c60..6fe53caa1d81 100644 --- a/numpy/core/include/numpy/npy_3kcompat.h +++ b/numpy/core/include/numpy/npy_3kcompat.h @@ -13,11 +13,9 @@ #include #include -#if PY_VERSION_HEX >= 0x03000000 #ifndef NPY_PY3K #define NPY_PY3K 1 #endif -#endif #include "numpy/npy_common.h" #include "numpy/ndarrayobject.h" diff --git a/numpy/core/src/multiarray/scalartypes.c.src b/numpy/core/src/multiarray/scalartypes.c.src index 91ee64b5f112..4cef01f89c16 100644 --- a/numpy/core/src/multiarray/scalartypes.c.src +++ b/numpy/core/src/multiarray/scalartypes.c.src @@ -1293,7 +1293,6 @@ gentype_sizeof(PyObject *self) return PyLong_FromSsize_t(nbytes); } -#if PY_VERSION_HEX >= 0x03000000 NPY_NO_EXPORT void gentype_struct_free(PyObject *ptr) { @@ -1307,17 +1306,6 @@ gentype_struct_free(PyObject *ptr) PyArray_free(arrif->shape); PyArray_free(arrif); } -#else -NPY_NO_EXPORT void -gentype_struct_free(void *ptr, void *arg) -{ - PyArrayInterface *arrif = (PyArrayInterface *)ptr; - Py_DECREF((PyObject *)arg); - Py_XDECREF(arrif->descr); - PyArray_free(arrif->shape); - PyArray_free(arrif); -} -#endif static PyObject * gentype_struct_get(PyObject *self) diff --git a/numpy/core/src/multiarray/scalartypes.h b/numpy/core/src/multiarray/scalartypes.h index 83b188128aaf..861f2c943e98 100644 --- a/numpy/core/src/multiarray/scalartypes.h +++ b/numpy/core/src/multiarray/scalartypes.h @@ -19,13 +19,8 @@ initialize_casting_tables(void); NPY_NO_EXPORT void initialize_numeric_types(void); -#if PY_VERSION_HEX >= 0x03000000 NPY_NO_EXPORT void gentype_struct_free(PyObject *ptr); -#else -NPY_NO_EXPORT void -gentype_struct_free(void *ptr, void *arg); -#endif NPY_NO_EXPORT int is_anyscalar_exact(PyObject *obj); diff --git a/numpy/core/src/umath/_rational_tests.c.src b/numpy/core/src/umath/_rational_tests.c.src index 17fffdae2f79..b2b75da74c98 100644 --- a/numpy/core/src/umath/_rational_tests.c.src +++ b/numpy/core/src/umath/_rational_tests.c.src @@ -609,9 +609,6 @@ static PyNumberMethods pyrational_as_number = { pyrational_add, /* nb_add */ pyrational_subtract, /* nb_subtract */ pyrational_multiply, /* nb_multiply */ -#if PY_MAJOR_VERSION < 3 - pyrational_divide, /* nb_divide */ -#endif pyrational_remainder, /* nb_remainder */ 0, /* nb_divmod */ 0, /* nb_power */ @@ -625,27 +622,13 @@ static PyNumberMethods pyrational_as_number = { 0, /* nb_and */ 0, /* nb_xor */ 0, /* nb_or */ -#if PY_MAJOR_VERSION < 3 - 0, /* nb_coerce */ -#endif pyrational_int, /* nb_int */ -#if PY_MAJOR_VERSION < 3 - pyrational_int, /* nb_long */ -#else 0, /* reserved */ -#endif pyrational_float, /* nb_float */ -#if PY_MAJOR_VERSION < 3 - 0, /* nb_oct */ - 0, /* nb_hex */ -#endif 0, /* nb_inplace_add */ 0, /* nb_inplace_subtract */ 0, /* nb_inplace_multiply */ -#if PY_MAJOR_VERSION < 3 - 0, /* nb_inplace_divide */ -#endif 0, /* nb_inplace_remainder */ 0, /* nb_inplace_power */ 0, /* nb_inplace_lshift */ diff --git a/numpy/core/src/umath/ufunc_object.c b/numpy/core/src/umath/ufunc_object.c index 1dc5819773e0..7bf530b6b102 100644 --- a/numpy/core/src/umath/ufunc_object.c +++ b/numpy/core/src/umath/ufunc_object.c @@ -929,22 +929,9 @@ parse_ufunc_keywords(PyUFuncObject *ufunc, PyObject *kwds, PyObject **kwnames, . } } else { -#if PY_VERSION_HEX >= 0x03000000 PyErr_Format(PyExc_TypeError, "'%S' is an invalid keyword to ufunc '%s'", key, ufunc_get_name_cstr(ufunc)); -#else - char *str = PyString_AsString(key); - if (str == NULL) { - PyErr_Clear(); - PyErr_SetString(PyExc_TypeError, "invalid keyword argument"); - } - else { - PyErr_Format(PyExc_TypeError, - "'%s' is an invalid keyword to ufunc '%s'", - str, ufunc_get_name_cstr(ufunc)); - } -#endif return -1; } } @@ -5068,21 +5055,12 @@ _free_loop1d_list(PyUFunc_Loop1d *data) } } -#if PY_VERSION_HEX >= 0x03000000 static void _loop1d_list_free(PyObject *ptr) { PyUFunc_Loop1d *data = (PyUFunc_Loop1d *)PyCapsule_GetPointer(ptr, NULL); _free_loop1d_list(data); } -#else -static void -_loop1d_list_free(void *ptr) -{ - PyUFunc_Loop1d *data = (PyUFunc_Loop1d *)ptr; - _free_loop1d_list(data); -} -#endif /* diff --git a/numpy/f2py/cfuncs.py b/numpy/f2py/cfuncs.py index cede0611950a..31faa452848e 100644 --- a/numpy/f2py/cfuncs.py +++ b/numpy/f2py/cfuncs.py @@ -646,7 +646,6 @@ tmp = obj; Py_INCREF(tmp); } -#if PY_VERSION_HEX >= 0x03000000 else if (PyUnicode_Check(obj)) { tmp = PyUnicode_AsASCIIString(obj); } @@ -661,11 +660,6 @@ tmp = NULL; } } -#else - else { - tmp = PyObject_Str(obj); - } -#endif if (tmp == NULL) goto capi_fail; if (*len == -1) *len = PyString_GET_SIZE(tmp); @@ -1094,13 +1088,8 @@ fprintf(stderr,\"Call-back argument must be function|instance|instance.__call__|f2py-function but got %s.\\n\",(fun==NULL?\"NULL\":Py_TYPE(fun)->tp_name)); goto capi_fail; } -#if PY_VERSION_HEX >= 0x03000000 if (PyObject_HasAttrString(tmp_fun,\"__code__\")) { if (PyObject_HasAttrString(tmp = PyObject_GetAttrString(tmp_fun,\"__code__\"),\"co_argcount\")) { -#else - if (PyObject_HasAttrString(tmp_fun,\"func_code\")) { - if (PyObject_HasAttrString(tmp = PyObject_GetAttrString(tmp_fun,\"func_code\"),\"co_argcount\")) { -#endif PyObject *tmp_argcount = PyObject_GetAttrString(tmp,\"co_argcount\"); Py_DECREF(tmp); if (tmp_argcount == NULL) { @@ -1111,13 +1100,8 @@ } } /* Get the number of optional arguments */ -#if PY_VERSION_HEX >= 0x03000000 if (PyObject_HasAttrString(tmp_fun,\"__defaults__\")) { if (PyTuple_Check(tmp = PyObject_GetAttrString(tmp_fun,\"__defaults__\"))) -#else - if (PyObject_HasAttrString(tmp_fun,\"func_defaults\")) { - if (PyTuple_Check(tmp = PyObject_GetAttrString(tmp_fun,\"func_defaults\"))) -#endif opt = PyTuple_Size(tmp); Py_XDECREF(tmp); } diff --git a/numpy/f2py/rules.py b/numpy/f2py/rules.py index a147f94b4db8..2d9d05260da9 100755 --- a/numpy/f2py/rules.py +++ b/numpy/f2py/rules.py @@ -180,7 +180,6 @@ \t{NULL,NULL} }; -#if PY_VERSION_HEX >= 0x03000000 static struct PyModuleDef moduledef = { \tPyModuleDef_HEAD_INIT, \t"#modulename#", @@ -192,16 +191,11 @@ \tNULL, \tNULL }; -#endif PyMODINIT_FUNC PyInit_#modulename#(void) { \tint i; \tPyObject *m,*d, *s, *tmp; -#if PY_VERSION_HEX >= 0x03000000 \tm = #modulename#_module = PyModule_Create(&moduledef); -#else -\tm = #modulename#_module = Py_InitModule(\"#modulename#\", f2py_module_methods); -#endif \tPy_TYPE(&PyFortran_Type) = &PyType_Type; \timport_array(); \tif (PyErr_Occurred()) @@ -210,11 +204,7 @@ \ts = PyString_FromString(\"$R""" + """evision: $\"); \tPyDict_SetItemString(d, \"__version__\", s); \tPy_DECREF(s); -#if PY_VERSION_HEX >= 0x03000000 \ts = PyUnicode_FromString( -#else -\ts = PyString_FromString( -#endif \t\t\"This module '#modulename#' is auto-generated with f2py (version:#f2py_version#).\\nFunctions:\\n\"\n#docs#\".\"); \tPyDict_SetItemString(d, \"__doc__\", s); \tPy_DECREF(s); @@ -442,11 +432,7 @@ tmp = F2PyCapsule_FromVoidPtr((void*)#F_FUNC#(#name_lower#,#NAME#),NULL); PyObject_SetAttrString(o,"_cpointer", tmp); Py_DECREF(tmp); -#if PY_VERSION_HEX >= 0x03000000 s = PyUnicode_FromString("#name#"); -#else - s = PyString_FromString("#name#"); -#endif PyObject_SetAttrString(o,"__name__", s); Py_DECREF(s); } @@ -484,11 +470,7 @@ tmp = F2PyCapsule_FromVoidPtr((void*)#F_FUNC#(#name_lower#,#NAME#),NULL); PyObject_SetAttrString(o,"_cpointer", tmp); Py_DECREF(tmp); -#if PY_VERSION_HEX >= 0x03000000 s = PyUnicode_FromString("#name#"); -#else - s = PyString_FromString("#name#"); -#endif PyObject_SetAttrString(o,"__name__", s); Py_DECREF(s); } diff --git a/numpy/f2py/src/fortranobject.c b/numpy/f2py/src/fortranobject.c index eb1050dd7108..973741ca78a3 100644 --- a/numpy/f2py/src/fortranobject.c +++ b/numpy/f2py/src/fortranobject.c @@ -115,14 +115,6 @@ fortran_dealloc(PyFortranObject *fp) { } -#if PY_VERSION_HEX >= 0x03000000 -#else -static PyMethodDef fortran_methods[] = { - {NULL, NULL} /* sentinel */ -}; -#endif - - /* Returns number of bytes consumed from buf, or -1 on error. */ static Py_ssize_t format_def(char *buf, Py_ssize_t size, FortranDataDef def) @@ -242,11 +234,7 @@ fortran_doc(FortranDataDef def) size--; /* p now points one beyond the last character of the string in buf */ -#if PY_VERSION_HEX >= 0x03000000 s = PyUnicode_FromStringAndSize(buf, p - buf); -#else - s = PyString_FromStringAndSize(buf, p - buf); -#endif PyMem_Free(buf); return s; @@ -306,7 +294,6 @@ fortran_getattr(PyFortranObject *fp, char *name) { return fp->dict; } if (strcmp(name,"__doc__")==0) { -#if PY_VERSION_HEX >= 0x03000000 PyObject *s = PyUnicode_FromString(""), *s2, *s3; for (i=0;ilen;i++) { s2 = fortran_doc(fp->defs[i]); @@ -315,11 +302,6 @@ fortran_getattr(PyFortranObject *fp, char *name) { Py_DECREF(s); s = s3; } -#else - PyObject *s = PyString_FromString(""); - for (i=0;ilen;i++) - PyString_ConcatAndDel(&s,fortran_doc(fp->defs[i])); -#endif if (PyDict_SetItemString(fp->dict, name, s)) return NULL; return s; @@ -330,7 +312,6 @@ fortran_getattr(PyFortranObject *fp, char *name) { return NULL; return cobj; } -#if PY_VERSION_HEX >= 0x03000000 if (1) { PyObject *str, *ret; str = PyUnicode_FromString(name); @@ -338,9 +319,6 @@ fortran_getattr(PyFortranObject *fp, char *name) { Py_DECREF(str); return ret; } -#else - return Py_FindMethod(fortran_methods, (PyObject *)fp, name); -#endif } static int @@ -434,33 +412,19 @@ fortran_repr(PyFortranObject *fp) PyObject *name = NULL, *repr = NULL; name = PyObject_GetAttrString((PyObject *)fp, "__name__"); PyErr_Clear(); -#if PY_VERSION_HEX >= 0x03000000 if (name != NULL && PyUnicode_Check(name)) { repr = PyUnicode_FromFormat("", name); } else { repr = PyUnicode_FromString(""); } -#else - if (name != NULL && PyString_Check(name)) { - repr = PyString_FromFormat("", PyString_AsString(name)); - } - else { - repr = PyString_FromString(""); - } -#endif Py_XDECREF(name); return repr; } PyTypeObject PyFortran_Type = { -#if PY_VERSION_HEX >= 0x03000000 PyVarObject_HEAD_INIT(NULL, 0) -#else - PyObject_HEAD_INIT(0) - 0, /*ob_size*/ -#endif "fortran", /*tp_name*/ sizeof(PyFortranObject), /*tp_basicsize*/ 0, /*tp_itemsize*/ diff --git a/numpy/f2py/src/fortranobject.h b/numpy/f2py/src/fortranobject.h index 21f1977eb3b2..5c382ab7b71c 100644 --- a/numpy/f2py/src/fortranobject.h +++ b/numpy/f2py/src/fortranobject.h @@ -82,20 +82,10 @@ typedef struct { extern PyObject * PyFortranObject_New(FortranDataDef* defs, f2py_void_func init); extern PyObject * PyFortranObject_NewAsAttr(FortranDataDef* defs); -#if PY_VERSION_HEX >= 0x03000000 - PyObject * F2PyCapsule_FromVoidPtr(void *ptr, void (*dtor)(PyObject *)); void * F2PyCapsule_AsVoidPtr(PyObject *obj); int F2PyCapsule_Check(PyObject *ptr); -#else - -PyObject * F2PyCapsule_FromVoidPtr(void *ptr, void (*dtor)(void *)); -void * F2PyCapsule_AsVoidPtr(PyObject *ptr); -int F2PyCapsule_Check(PyObject *ptr); - -#endif - #define ISCONTIGUOUS(m) (PyArray_FLAGS(m) & NPY_ARRAY_C_CONTIGUOUS) #define F2PY_INTENT_IN 1 #define F2PY_INTENT_INOUT 2 diff --git a/numpy/f2py/tests/src/array_from_pyobj/wrapmodule.c b/numpy/f2py/tests/src/array_from_pyobj/wrapmodule.c index 369221c75d26..83c0da2cf682 100644 --- a/numpy/f2py/tests/src/array_from_pyobj/wrapmodule.c +++ b/numpy/f2py/tests/src/array_from_pyobj/wrapmodule.c @@ -129,7 +129,6 @@ static PyMethodDef f2py_module_methods[] = { {NULL,NULL} }; -#if PY_VERSION_HEX >= 0x03000000 static struct PyModuleDef moduledef = { PyModuleDef_HEAD_INIT, "test_array_from_pyobj_ext", @@ -141,7 +140,6 @@ static struct PyModuleDef moduledef = { NULL, NULL }; -#endif PyMODINIT_FUNC PyInit_test_array_from_pyobj_ext(void) { PyObject *m,*d, *s; diff --git a/tools/swig/numpy.i b/tools/swig/numpy.i index 36bb55c98cff..8416e82f3a90 100644 --- a/tools/swig/numpy.i +++ b/tools/swig/numpy.i @@ -120,11 +120,6 @@ if (PyDict_Check( py_obj)) return "dict" ; if (PyList_Check( py_obj)) return "list" ; if (PyTuple_Check( py_obj)) return "tuple" ; -%#if PY_MAJOR_VERSION < 3 - if (PyFile_Check( py_obj)) return "file" ; - if (PyModule_Check( py_obj)) return "module" ; - if (PyInstance_Check(py_obj)) return "instance" ; -%#endif return "unknown type"; } @@ -545,7 +540,7 @@ const npy_intp *dims = array_dimensions(ary); for (i=0; i < nd; ++i) n_non_one += (dims[i] != 1) ? 1 : 0; - if (n_non_one > 1) + if (n_non_one > 1) array_clearflags(ary,NPY_ARRAY_CARRAY); array_enableflags(ary,NPY_ARRAY_FARRAY); /* Recompute the strides */ diff --git a/tools/swig/pyfragments.swg b/tools/swig/pyfragments.swg index 97ca8cf97c31..ce2452f8020d 100644 --- a/tools/swig/pyfragments.swg +++ b/tools/swig/pyfragments.swg @@ -75,21 +75,6 @@ SWIGINTERN int SWIG_AsVal_dec(unsigned long)(PyObject *obj, unsigned long *val) { - %#if PY_VERSION_HEX < 0x03000000 - if (PyInt_Check(obj)) - { - long v = PyInt_AsLong(obj); - if (v >= 0) - { - if (val) *val = v; - return SWIG_OK; - } - else - { - return SWIG_OverflowError; - } - } else - %#endif if (PyLong_Check(obj)) { unsigned long v = PyLong_AsUnsignedLong(obj); if (!PyErr_Occurred()) { From 22888e12b64c3b9def9c78d2eeefef88b1cfa6fe Mon Sep 17 00:00:00 2001 From: Mark Harfouche Date: Fri, 29 Nov 2019 14:07:22 -0500 Subject: [PATCH 0108/4713] MAINT: cleanup compat.py3k.py --- numpy/compat/py3k.py | 169 +++++++++++++------------------------------ 1 file changed, 51 insertions(+), 118 deletions(-) diff --git a/numpy/compat/py3k.py b/numpy/compat/py3k.py index f24a8af27f9c..19d219ed5c7c 100644 --- a/numpy/compat/py3k.py +++ b/numpy/compat/py3k.py @@ -18,76 +18,48 @@ import sys import os -try: - from pathlib import Path, PurePath -except ImportError: - Path = PurePath = None - -if sys.version_info[0] >= 3: - import io - - try: - import pickle5 as pickle - except ImportError: - import pickle +from pathlib import Path, PurePath +import io - long = int - integer_types = (int,) - basestring = str - unicode = str - bytes = bytes - - def asunicode(s): - if isinstance(s, bytes): - return s.decode('latin1') - return str(s) - - def asbytes(s): - if isinstance(s, bytes): - return s - return str(s).encode('latin1') +import abc +from abc import ABC as abc_ABC - def asstr(s): - if isinstance(s, bytes): - return s.decode('latin1') - return str(s) +try: + import pickle5 as pickle +except ImportError: + import pickle - def isfileobj(f): - return isinstance(f, (io.FileIO, io.BufferedReader, io.BufferedWriter)) +long = int +integer_types = (int,) +basestring = str +unicode = str +bytes = bytes - def open_latin1(filename, mode='r'): - return open(filename, mode=mode, encoding='iso-8859-1') +def asunicode(s): + if isinstance(s, bytes): + return s.decode('latin1') + return str(s) - def sixu(s): +def asbytes(s): + if isinstance(s, bytes): return s + return str(s).encode('latin1') - strchar = 'U' - -else: - import cpickle as pickle +def asstr(s): + if isinstance(s, bytes): + return s.decode('latin1') + return str(s) - bytes = str - long = long - basestring = basestring - unicode = unicode - integer_types = (int, long) - asbytes = str - asstr = str - strchar = 'S' +def isfileobj(f): + return isinstance(f, (io.FileIO, io.BufferedReader, io.BufferedWriter)) - def isfileobj(f): - return isinstance(f, file) +def open_latin1(filename, mode='r'): + return open(filename, mode=mode, encoding='iso-8859-1') - def asunicode(s): - if isinstance(s, unicode): - return s - return str(s).decode('ascii') +def sixu(s): + return s - def open_latin1(filename, mode='r'): - return open(filename, mode=mode) - - def sixu(s): - return unicode(s, 'unicode_escape') +strchar = 'U' def getexception(): return sys.exc_info()[1] @@ -134,69 +106,30 @@ def __exit__(self, *excinfo): pass -if sys.version_info[0] >= 3 and sys.version_info[1] >= 4: - def npy_load_module(name, fn, info=None): - """ - Load a module. - - .. versionadded:: 1.11.2 - - Parameters - ---------- - name : str - Full module name. - fn : str - Path to module file. - info : tuple, optional - Only here for backward compatibility with Python 2.*. - - Returns - ------- - mod : module - - """ - import importlib.machinery - return importlib.machinery.SourceFileLoader(name, fn).load_module() -else: - def npy_load_module(name, fn, info=None): - """ - Load a module. - - .. versionadded:: 1.11.2 +def npy_load_module(name, fn, info=None): + """ + Load a module. - Parameters - ---------- - name : str - Full module name. - fn : str - Path to module file. - info : tuple, optional - Information as returned by `imp.find_module` - (suffix, mode, type). + .. versionadded:: 1.11.2 - Returns - ------- - mod : module + Parameters + ---------- + name : str + Full module name. + fn : str + Path to module file. + info : tuple, optional + Only here for backward compatibility with Python 2.*. - """ - import imp - if info is None: - path = os.path.dirname(fn) - fo, fn, info = imp.find_module(name, [path]) - else: - fo = open(fn, info[1]) - try: - mod = imp.load_module(name, fo, fn, info) - finally: - fo.close() - return mod + Returns + ------- + mod : module -# backport abc.ABC -import abc -if sys.version_info[:2] >= (3, 4): - abc_ABC = abc.ABC -else: - abc_ABC = abc.ABCMeta('ABC', (object,), {'__slots__': ()}) + """ + # Explicitly lazy import this to avoid paying the cost + # of importing importlib at startup + from importlib.machinery import SourceFileLoader + return SourceFileLoader(name, fn).load_module() # Backport os.fs_path, os.PathLike, and PurePath.__fspath__ From 963692da48ac8baf692357b453e2945122fd4eb5 Mon Sep 17 00:00:00 2001 From: Jon Dufresne Date: Fri, 3 Jan 2020 11:09:39 -0500 Subject: [PATCH 0109/4713] MAINT: Remove unused int_asbuffer On Python 3, int_asbuffer throws NotImplementedError and goes unused internally. Fixes #12425 --- doc/Py3K.rst.txt | 12 --- .../upcoming_changes/15229.compatibility.rst | 7 ++ numpy/core/multiarray.py | 2 +- numpy/core/numeric.py | 4 +- numpy/core/src/multiarray/multiarraymodule.c | 95 ------------------- numpy/tests/test_public_api.py | 1 - 6 files changed, 10 insertions(+), 111 deletions(-) create mode 100644 doc/release/upcoming_changes/15229.compatibility.rst diff --git a/doc/Py3K.rst.txt b/doc/Py3K.rst.txt index 3ff2f9c5d8eb..8c170e1ba90a 100644 --- a/doc/Py3K.rst.txt +++ b/doc/Py3K.rst.txt @@ -396,14 +396,6 @@ There are a couple of places that need further attention: In some cases, this returns a buffer object on Python 2. On Python 3, there is no stand-alone buffer object, so we return a byte array instead. -- multiarray.int_asbuffer - - Converts an integer to a void* pointer -- in Python. - - Should we just remove this for Py3? It doesn't seem like it is used - anywhere, and it doesn't sound very useful. - - The Py2/Py3 compatible PyBufferMethods definition looks like:: NPY_NO_EXPORT PyBufferProcs array_as_buffer = { @@ -430,10 +422,6 @@ The Py2/Py3 compatible PyBufferMethods definition looks like:: Produce PEP 3118 format strings for array scalar objects. -.. todo:: - - Figure out what to do with int_asbuffer - .. todo:: There's stuff to clean up in numarray/_capi.c diff --git a/doc/release/upcoming_changes/15229.compatibility.rst b/doc/release/upcoming_changes/15229.compatibility.rst new file mode 100644 index 000000000000..404f7774fd64 --- /dev/null +++ b/doc/release/upcoming_changes/15229.compatibility.rst @@ -0,0 +1,7 @@ +Removed ``multiarray.int_asbuffer`` +----------------------------------- + +As part of the continued removal of Python 2 compatibility, +``multiarray.int_asbuffer`` was removed. On Python 3, it threw a +``NotImplementedError`` and was unused internally. It is expected that there +are no downstream use cases for this method with Python 3. diff --git a/numpy/core/multiarray.py b/numpy/core/multiarray.py index c0fcc10ffede..01fca1df5daf 100644 --- a/numpy/core/multiarray.py +++ b/numpy/core/multiarray.py @@ -33,7 +33,7 @@ 'digitize', 'dot', 'dragon4_positional', 'dragon4_scientific', 'dtype', 'empty', 'empty_like', 'error', 'flagsobj', 'flatiter', 'format_longfloat', 'frombuffer', 'fromfile', 'fromiter', 'fromstring', 'inner', - 'int_asbuffer', 'interp', 'interp_complex', 'is_busday', 'lexsort', + 'interp', 'interp_complex', 'is_busday', 'lexsort', 'matmul', 'may_share_memory', 'min_scalar_type', 'ndarray', 'nditer', 'nested_iters', 'normalize_axis_index', 'packbits', 'promote_types', 'putmask', 'ravel_multi_index', 'result_type', 'scalar', diff --git a/numpy/core/numeric.py b/numpy/core/numeric.py index af289ca3df1f..ae3dcd07aabb 100644 --- a/numpy/core/numeric.py +++ b/numpy/core/numeric.py @@ -15,7 +15,7 @@ WRAP, arange, array, broadcast, can_cast, compare_chararrays, concatenate, copyto, dot, dtype, empty, empty_like, flatiter, frombuffer, fromfile, fromiter, fromstring, - inner, int_asbuffer, lexsort, matmul, may_share_memory, + inner, lexsort, matmul, may_share_memory, min_scalar_type, ndarray, nditer, nested_iters, promote_types, putmask, result_type, set_numeric_ops, shares_memory, vdot, where, zeros, normalize_axis_index) @@ -50,7 +50,7 @@ __all__ = [ 'newaxis', 'ndarray', 'flatiter', 'nditer', 'nested_iters', 'ufunc', 'arange', 'array', 'zeros', 'count_nonzero', 'empty', 'broadcast', 'dtype', - 'fromstring', 'fromfile', 'frombuffer', 'int_asbuffer', 'where', + 'fromstring', 'fromfile', 'frombuffer', 'where', 'argwhere', 'copyto', 'concatenate', 'fastCopyAndTranspose', 'lexsort', 'set_numeric_ops', 'can_cast', 'promote_types', 'min_scalar_type', 'result_type', 'isfortran', 'empty_like', 'zeros_like', 'ones_like', diff --git a/numpy/core/src/multiarray/multiarraymodule.c b/numpy/core/src/multiarray/multiarraymodule.c index eb593bdb5741..58f64f0bb0b4 100644 --- a/numpy/core/src/multiarray/multiarraymodule.c +++ b/numpy/core/src/multiarray/multiarraymodule.c @@ -3329,98 +3329,6 @@ buffer_buffer(PyObject *NPY_UNUSED(dummy), PyObject *args, PyObject *kwds) } #endif -#ifndef _MSC_VER -#include -#include -jmp_buf _NPY_SIGSEGV_BUF; -static void -_SigSegv_Handler(int signum) -{ - longjmp(_NPY_SIGSEGV_BUF, signum); -} -#endif - -#define _test_code() { \ - test = *((char*)memptr); \ - if (!ro) { \ - *((char *)memptr) = '\0'; \ - *((char *)memptr) = test; \ - } \ - test = *((char*)memptr+size-1); \ - if (!ro) { \ - *((char *)memptr+size-1) = '\0'; \ - *((char *)memptr+size-1) = test; \ - } \ - } - -static PyObject * -as_buffer(PyObject *NPY_UNUSED(dummy), PyObject *args, PyObject *kwds) -{ - PyObject *mem; - Py_ssize_t size; - npy_bool ro = NPY_FALSE, check = NPY_TRUE; - void *memptr; - static char *kwlist[] = {"mem", "size", "readonly", "check", NULL}; - - if (!PyArg_ParseTupleAndKeywords(args, kwds, - "O" NPY_SSIZE_T_PYFMT "|O&O&:int_asbuffer", kwlist, - &mem, &size, PyArray_BoolConverter, &ro, - PyArray_BoolConverter, &check)) { - return NULL; - } - memptr = PyLong_AsVoidPtr(mem); - if (memptr == NULL) { - return NULL; - } - if (check) { - /* - * Try to dereference the start and end of the memory region - * Catch segfault and report error if it occurs - */ - char test; - int err = 0; - -#ifdef _MSC_VER - __try { - _test_code(); - } - __except(1) { - err = 1; - } -#else - PyOS_sighandler_t _npy_sig_save; - _npy_sig_save = PyOS_setsig(SIGSEGV, _SigSegv_Handler); - if (setjmp(_NPY_SIGSEGV_BUF) == 0) { - _test_code(); - } - else { - err = 1; - } - PyOS_setsig(SIGSEGV, _npy_sig_save); -#endif - if (err) { - PyErr_SetString(PyExc_ValueError, - "cannot use memory location as a buffer."); - return NULL; - } - } - - -#if defined(NPY_PY3K) - PyErr_SetString(PyExc_RuntimeError, - "XXX -- not implemented!"); - return NULL; -#else - if (ro) { - return PyBuffer_FromMemory(memptr, size); - } - return PyBuffer_FromReadWriteMemory(memptr, size); -#endif -} - -#undef _test_code - - /* * Prints floating-point scalars using the Dragon4 algorithm, scientific mode. * See docstring of `np.format_float_scientific` for description of arguments. @@ -4237,9 +4145,6 @@ static struct PyMethodDef array_module_methods[] = { (PyCFunction)buffer_buffer, METH_VARARGS | METH_KEYWORDS, NULL}, #endif - {"int_asbuffer", - (PyCFunction)as_buffer, - METH_VARARGS | METH_KEYWORDS, NULL}, {"format_longfloat", (PyCFunction)format_longfloat, METH_VARARGS | METH_KEYWORDS, NULL}, diff --git a/numpy/tests/test_public_api.py b/numpy/tests/test_public_api.py index 9f5ae8a9268f..4ee84034d49c 100644 --- a/numpy/tests/test_public_api.py +++ b/numpy/tests/test_public_api.py @@ -48,7 +48,6 @@ def test_numpy_namespace(): 'fastCopyAndTranspose': 'numpy.core._multiarray_umath._fastCopyAndTranspose', 'get_array_wrap': 'numpy.lib.shape_base.get_array_wrap', 'get_include': 'numpy.lib.utils.get_include', - 'int_asbuffer': 'numpy.core._multiarray_umath.int_asbuffer', 'mafromtxt': 'numpy.lib.npyio.mafromtxt', 'ndfromtxt': 'numpy.lib.npyio.ndfromtxt', 'recfromcsv': 'numpy.lib.npyio.recfromcsv', From 9404c51942afb4bda3c94f9bc891ea45dea061ea Mon Sep 17 00:00:00 2001 From: Seth Troisi Date: Sat, 4 Jan 2020 17:40:09 -0800 Subject: [PATCH 0110/4713] Update HOWTO_RELEASE.rst --- doc/HOWTO_RELEASE.rst.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/HOWTO_RELEASE.rst.txt b/doc/HOWTO_RELEASE.rst.txt index 99f6a0e40a8c..30d4a471c019 100644 --- a/doc/HOWTO_RELEASE.rst.txt +++ b/doc/HOWTO_RELEASE.rst.txt @@ -40,7 +40,7 @@ Release Scripts Supported platforms and versions ================================ -Python 2.7 and >=3.4 are the currently supported versions when building from +Python >=3.5 are the currently supported versions when building from source. We test NumPy against all these versions every time we merge code to master. Binary installers may be available for a subset of these versions (see below). @@ -48,7 +48,7 @@ below). OS X ---- -Python 2.7 and >=3.4 are the versions for which we provide binary installers. +Python >=3.5 are the versions for which we provide binary installers. OS X versions >= 10.6 are supported. We build binary wheels for OSX that are compatible with Python.org Python, system Python, homebrew and macports - see this `OSX wheel building summary @@ -57,7 +57,7 @@ this `OSX wheel building summary Windows ------- -We build 32- and 64-bit wheels for Python 2.7, 3.4, 3.5 on Windows. Windows +We build 32- and 64-bit wheels for Python 3.5 on Windows. Windows XP, Vista, 7, 8 and 10 are supported. We build NumPy using the MSVC compilers on Appveyor, but we are hoping to update to a `mingw-w64 toolchain `_. The Windows wheels use ATLAS for BLAS / LAPACK. From c31cc36a8a814ed4844a2a553454185601914a5a Mon Sep 17 00:00:00 2001 From: Jon Dufresne Date: Sun, 5 Jan 2020 00:53:30 -0500 Subject: [PATCH 0111/4713] MAINT: Remove implicit inheritance from object class (#15236) Inheriting from object was necessary for Python 2 compatibility to use new-style classes. In Python 3, this is unnecessary as there are no old-style classes. Dropping the object is more idiomatic Python. --- benchmarks/benchmarks/bench_function_base.py | 2 +- benchmarks/benchmarks/bench_overrides.py | 2 +- benchmarks/benchmarks/bench_ufunc.py | 2 +- benchmarks/benchmarks/common.py | 2 +- doc/TESTS.rst.txt | 4 +- .../reference/random/multithreading.rst | 2 +- numpy/_globals.py | 2 +- numpy/_pytesttester.py | 2 +- numpy/compat/py3k.py | 2 +- numpy/core/_internal.py | 12 +- numpy/core/_ufunc_config.py | 4 +- numpy/core/arrayprint.py | 14 +- numpy/core/code_generators/genapi.py | 14 +- numpy/core/code_generators/generate_umath.py | 8 +- numpy/core/getlimits.py | 6 +- numpy/core/machar.py | 2 +- numpy/core/records.py | 2 +- numpy/core/setup.py | 2 +- numpy/core/tests/_locales.py | 2 +- numpy/core/tests/test_abc.py | 2 +- numpy/core/tests/test_arrayprint.py | 10 +- numpy/core/tests/test_datetime.py | 4 +- numpy/core/tests/test_defchararray.py | 16 +- numpy/core/tests/test_deprecations.py | 8 +- numpy/core/tests/test_dtype.py | 26 +-- numpy/core/tests/test_einsum.py | 4 +- numpy/core/tests/test_errstate.py | 2 +- numpy/core/tests/test_function_base.py | 8 +- numpy/core/tests/test_getlimits.py | 16 +- numpy/core/tests/test_half.py | 2 +- numpy/core/tests/test_indexerrors.py | 2 +- numpy/core/tests/test_indexing.py | 32 ++-- numpy/core/tests/test_item_selection.py | 2 +- numpy/core/tests/test_longdouble.py | 2 +- numpy/core/tests/test_machar.py | 2 +- numpy/core/tests/test_mem_overlap.py | 6 +- numpy/core/tests/test_memmap.py | 2 +- numpy/core/tests/test_multiarray.py | 180 +++++++++--------- numpy/core/tests/test_nditer.py | 2 +- numpy/core/tests/test_numeric.py | 70 +++---- numpy/core/tests/test_numerictypes.py | 26 +-- numpy/core/tests/test_overrides.py | 30 +-- numpy/core/tests/test_records.py | 6 +- numpy/core/tests/test_regression.py | 12 +- numpy/core/tests/test_scalar_ctors.py | 4 +- numpy/core/tests/test_scalar_methods.py | 2 +- numpy/core/tests/test_scalarbuffer.py | 2 +- numpy/core/tests/test_scalarinherit.py | 6 +- numpy/core/tests/test_scalarmath.py | 30 +-- numpy/core/tests/test_scalarprint.py | 2 +- numpy/core/tests/test_shape_base.py | 16 +- numpy/core/tests/test_ufunc.py | 12 +- numpy/core/tests/test_umath.py | 132 ++++++------- numpy/core/tests/test_umath_accuracy.py | 2 +- numpy/core/tests/test_umath_complex.py | 12 +- numpy/core/tests/test_unicode.py | 8 +- numpy/distutils/command/config.py | 2 +- numpy/distutils/cpuinfo.py | 2 +- numpy/distutils/fcompiler/environment.py | 2 +- numpy/distutils/misc_util.py | 4 +- numpy/distutils/npy_pkg_config.py | 4 +- numpy/distutils/system_info.py | 2 +- numpy/distutils/tests/test_exec_command.py | 8 +- numpy/distutils/tests/test_fcompiler_gnu.py | 4 +- numpy/distutils/tests/test_fcompiler_intel.py | 4 +- .../distutils/tests/test_fcompiler_nagfor.py | 2 +- numpy/distutils/tests/test_misc_util.py | 8 +- numpy/distutils/tests/test_npy_pkg_config.py | 4 +- numpy/distutils/tests/test_system_info.py | 2 +- numpy/doc/glossary.py | 4 +- numpy/doc/subclassing.py | 2 +- numpy/f2py/auxfuncs.py | 2 +- numpy/f2py/tests/test_array_from_pyobj.py | 10 +- numpy/f2py/tests/test_callback.py | 2 +- numpy/f2py/tests/util.py | 2 +- numpy/fft/tests/test_helper.py | 8 +- numpy/fft/tests/test_pocketfft.py | 6 +- numpy/lib/_datasource.py | 4 +- numpy/lib/_iotools.py | 6 +- numpy/lib/arrayterator.py | 2 +- numpy/lib/function_base.py | 2 +- numpy/lib/index_tricks.py | 10 +- numpy/lib/mixins.py | 2 +- numpy/lib/npyio.py | 6 +- numpy/lib/polynomial.py | 2 +- numpy/lib/stride_tricks.py | 2 +- numpy/lib/tests/test__datasource.py | 12 +- numpy/lib/tests/test__iotools.py | 8 +- numpy/lib/tests/test_arraypad.py | 24 +-- numpy/lib/tests/test_arraysetops.py | 6 +- numpy/lib/tests/test_financial.py | 2 +- numpy/lib/tests/test_function_base.py | 90 ++++----- numpy/lib/tests/test_histograms.py | 6 +- numpy/lib/tests/test_index_tricks.py | 16 +- numpy/lib/tests/test_io.py | 16 +- numpy/lib/tests/test_mixins.py | 4 +- numpy/lib/tests/test_nanfunctions.py | 14 +- numpy/lib/tests/test_polynomial.py | 2 +- numpy/lib/tests/test_recfunctions.py | 16 +- numpy/lib/tests/test_regression.py | 2 +- numpy/lib/tests/test_shape_base.py | 32 ++-- numpy/lib/tests/test_twodim_base.py | 20 +- numpy/lib/tests/test_type_check.py | 36 ++-- numpy/lib/tests/test_ufunclike.py | 2 +- numpy/lib/tests/test_utils.py | 2 +- numpy/lib/user_array.py | 2 +- numpy/lib/utils.py | 2 +- numpy/linalg/lapack_lite/clapack_scrub.py | 2 +- numpy/linalg/lapack_lite/fortran.py | 4 +- numpy/linalg/lapack_lite/make_lite.py | 4 +- numpy/linalg/tests/test_build.py | 4 +- numpy/linalg/tests/test_linalg.py | 26 +-- numpy/linalg/tests/test_regression.py | 2 +- numpy/ma/core.py | 20 +- numpy/ma/extras.py | 2 +- numpy/ma/mrecords.py | 2 +- numpy/ma/tests/test_core.py | 36 ++-- numpy/ma/tests/test_deprecations.py | 4 +- numpy/ma/tests/test_extras.py | 28 +-- numpy/ma/tests/test_mrecords.py | 6 +- numpy/ma/tests/test_old_ma.py | 6 +- numpy/ma/tests/test_regression.py | 2 +- numpy/ma/tests/test_subclassing.py | 4 +- numpy/ma/timer_comparison.py | 2 +- numpy/matrixlib/tests/test_defmatrix.py | 18 +- numpy/matrixlib/tests/test_interaction.py | 2 +- numpy/matrixlib/tests/test_masked_matrix.py | 6 +- numpy/matrixlib/tests/test_multiarray.py | 2 +- numpy/matrixlib/tests/test_numeric.py | 2 +- numpy/matrixlib/tests/test_regression.py | 2 +- numpy/polynomial/polyutils.py | 2 +- numpy/polynomial/tests/test_chebyshev.py | 24 +-- numpy/polynomial/tests/test_classes.py | 4 +- numpy/polynomial/tests/test_hermite.py | 20 +- numpy/polynomial/tests/test_hermite_e.py | 20 +- numpy/polynomial/tests/test_laguerre.py | 20 +- numpy/polynomial/tests/test_legendre.py | 20 +- numpy/polynomial/tests/test_polynomial.py | 16 +- numpy/polynomial/tests/test_polyutils.py | 4 +- numpy/polynomial/tests/test_printing.py | 4 +- numpy/random/tests/test_direct.py | 4 +- numpy/random/tests/test_generator_mt19937.py | 20 +- .../test_generator_mt19937_regressions.py | 4 +- numpy/random/tests/test_random.py | 18 +- numpy/random/tests/test_randomstate.py | 18 +- .../tests/test_randomstate_regression.py | 4 +- numpy/random/tests/test_regression.py | 4 +- numpy/random/tests/test_smoke.py | 2 +- numpy/testing/_private/noseclasses.py | 2 +- numpy/testing/_private/nosetester.py | 2 +- numpy/testing/_private/parameterized.py | 4 +- numpy/testing/_private/utils.py | 2 +- numpy/testing/print_coercion_tables.py | 2 +- numpy/testing/tests/test_decorators.py | 2 +- numpy/testing/tests/test_utils.py | 28 +-- numpy/tests/test_ctypeslib.py | 10 +- tools/allocation_tracking/alloc_hook.pyx | 2 +- .../allocation_tracking/track_allocations.py | 2 +- tools/npy_tempita/__init__.py | 12 +- tools/npy_tempita/_looper.py | 6 +- tools/refguide_check.py | 2 +- 161 files changed, 845 insertions(+), 845 deletions(-) diff --git a/benchmarks/benchmarks/bench_function_base.py b/benchmarks/benchmarks/bench_function_base.py index 3b4647773e8f..b1e59274986c 100644 --- a/benchmarks/benchmarks/bench_function_base.py +++ b/benchmarks/benchmarks/bench_function_base.py @@ -104,7 +104,7 @@ def wrapped(*args): return f -class SortGenerator(object): +class SortGenerator: # The size of the unsorted area in the "random unsorted area" # benchmarks AREA_SIZE = 100 diff --git a/benchmarks/benchmarks/bench_overrides.py b/benchmarks/benchmarks/bench_overrides.py index f03120efa5fe..e449517851ec 100644 --- a/benchmarks/benchmarks/bench_overrides.py +++ b/benchmarks/benchmarks/bench_overrides.py @@ -33,7 +33,7 @@ def mock_concatenate(arrays, axis=0, out=None): pass -class DuckArray(object): +class DuckArray: def __array_function__(self, func, types, args, kwargs): pass diff --git a/benchmarks/benchmarks/bench_ufunc.py b/benchmarks/benchmarks/bench_ufunc.py index 73159bd97903..9f45a72575ff 100644 --- a/benchmarks/benchmarks/bench_ufunc.py +++ b/benchmarks/benchmarks/bench_ufunc.py @@ -150,7 +150,7 @@ def time_add_scalar_conv_complex(self): (self.y + self.z) -class ArgPack(object): +class ArgPack: __slots__ = ['args', 'kwargs'] def __init__(self, *args, **kwargs): self.args = args diff --git a/benchmarks/benchmarks/common.py b/benchmarks/benchmarks/common.py index c6037dea9fb8..3fd81a1648d0 100644 --- a/benchmarks/benchmarks/common.py +++ b/benchmarks/benchmarks/common.py @@ -110,5 +110,5 @@ def get_indexes_rand_(): return indexes_rand_ -class Benchmark(object): +class Benchmark: goal_time = 0.25 diff --git a/doc/TESTS.rst.txt b/doc/TESTS.rst.txt index 14cb28df8cef..9023c7100c5d 100644 --- a/doc/TESTS.rst.txt +++ b/doc/TESTS.rst.txt @@ -119,7 +119,7 @@ that makes it hard to identify the test from the output of running the test suite with ``verbose=2`` (or similar verbosity setting). Use plain comments (``#``) if necessary. -Labeling tests +Labeling tests -------------- As an alternative to ``pytest.mark.