From ec62be21cf109dac436f9a68a84fbd674c1faebb Mon Sep 17 00:00:00 2001 From: Sebastian Berg Date: Mon, 8 Jun 2020 08:56:54 -0500 Subject: BUG: Remove non-threadsafe sigint handling from fft calculation The fft calculation is the only point in our code where this function is used. Allowing Ctrl+C, in FFT specifically used have more reasons, since before pocketfft, some array-sizes could lead to very large run-times. Pocketfft fixed that issue, and now FFT is not really any slower, faster, or memory hungry than any other NumPy operation so it feels it does not need this handling. Rather, if we can find a better solution, it should also be added to more functions. The reason for removal is that it is not only unsafe while the FFT is running (in theory). Multiple, threaded FFT run can easily leave the signal handler in a bad state, causing crashes if Ctrl+C (sigint) is given at any point after the call. It would be possible to patch that over, by only resetting the signal handler if we actually changed it (or even more complex tricks), or possibly only using this technique when on the main thread. But, all of these solutions seem to complicate things, when the main reason for why allowing sigint seems useful is gone with pocketfft. --- numpy/core/multiarray.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'numpy/core/multiarray.py') diff --git a/numpy/core/multiarray.py b/numpy/core/multiarray.py index 2cc2a8e71..b196687af 100644 --- a/numpy/core/multiarray.py +++ b/numpy/core/multiarray.py @@ -38,7 +38,7 @@ __all__ = [ 'nested_iters', 'normalize_axis_index', 'packbits', 'promote_types', 'putmask', 'ravel_multi_index', 'result_type', 'scalar', 'set_datetimeparse_function', 'set_legacy_print_mode', 'set_numeric_ops', - 'set_string_function', 'set_typeDict', 'shares_memory', 'test_interrupt', + 'set_string_function', 'set_typeDict', 'shares_memory', 'tracemalloc_domain', 'typeinfo', 'unpackbits', 'unravel_index', 'vdot', 'where', 'zeros'] -- cgit v1.2.1 From cfd553dad7c1f315b7508eb56ac4527afc444ebb Mon Sep 17 00:00:00 2001 From: Sebastian Berg Date: Thu, 30 Apr 2020 19:50:44 -0500 Subject: ENH: Implement concatenate dtype and casting keyword arguments Unfortunately, the casting was not consistent and sometimes used force casting (axis=None) while normally same kind casting was used. This thus deprecates the `force_casting` corner case, so that casting has to be provided in the future. --- numpy/core/multiarray.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'numpy/core/multiarray.py') diff --git a/numpy/core/multiarray.py b/numpy/core/multiarray.py index 10325050d..540c0568f 100644 --- a/numpy/core/multiarray.py +++ b/numpy/core/multiarray.py @@ -141,9 +141,9 @@ def empty_like(prototype, dtype=None, order=None, subok=None, shape=None): @array_function_from_c_func_and_dispatcher(_multiarray_umath.concatenate) -def concatenate(arrays, axis=None, out=None): +def concatenate(arrays, axis=None, out=None, dtype=None, casting=None): """ - concatenate((a1, a2, ...), axis=0, out=None) + concatenate((a1, a2, ...), axis=0, out=None, dtype=None, casting="same_kind") Join a sequence of arrays along an existing axis. @@ -159,6 +159,16 @@ def concatenate(arrays, axis=None, out=None): If provided, the destination to place the result. The shape must be correct, matching that of what concatenate would have returned if no out argument were specified. + dtype : str or dtype + If provided, the destination array will have this dtype. Cannot be + provided together with `out`. + + ..versionadded:: 1.19.0 + + casting : {'no', 'equiv', 'safe', 'same_kind', 'unsafe'}, optional + Controls what kind of data casting may occur. Defaults to 'same_kind'. + + ..versionadded:: 1.19.0 Returns ------- -- cgit v1.2.1 From 3cddaa9f6efe8d0975c2754ea8922050f3563acc Mon Sep 17 00:00:00 2001 From: Sebastian Berg Date: Wed, 20 May 2020 18:52:38 -0500 Subject: Apply suggestions from code review Co-authored-by: Eric Wieser --- numpy/core/multiarray.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'numpy/core/multiarray.py') diff --git a/numpy/core/multiarray.py b/numpy/core/multiarray.py index 540c0568f..fade479c1 100644 --- a/numpy/core/multiarray.py +++ b/numpy/core/multiarray.py @@ -141,7 +141,7 @@ def empty_like(prototype, dtype=None, order=None, subok=None, shape=None): @array_function_from_c_func_and_dispatcher(_multiarray_umath.concatenate) -def concatenate(arrays, axis=None, out=None, dtype=None, casting=None): +def concatenate(arrays, axis=None, out=None, *, dtype=None, casting=None): """ concatenate((a1, a2, ...), axis=0, out=None, dtype=None, casting="same_kind") -- cgit v1.2.1 From c8eb9d47c5562c665cb45d91bedbf689e0edf3f0 Mon Sep 17 00:00:00 2001 From: Sebastian Berg Date: Thu, 3 Sep 2020 10:23:20 -0500 Subject: DOC: Fixup deprecation dates --- numpy/core/multiarray.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'numpy/core/multiarray.py') diff --git a/numpy/core/multiarray.py b/numpy/core/multiarray.py index fade479c1..225c9554c 100644 --- a/numpy/core/multiarray.py +++ b/numpy/core/multiarray.py @@ -163,12 +163,12 @@ def concatenate(arrays, axis=None, out=None, *, dtype=None, casting=None): If provided, the destination array will have this dtype. Cannot be provided together with `out`. - ..versionadded:: 1.19.0 + ..versionadded:: 1.20.0 casting : {'no', 'equiv', 'safe', 'same_kind', 'unsafe'}, optional Controls what kind of data casting may occur. Defaults to 'same_kind'. - ..versionadded:: 1.19.0 + ..versionadded:: 1.20.0 Returns ------- -- cgit v1.2.1 From 60a1e10c4593736b188b38e7d7c51aefb213af6a Mon Sep 17 00:00:00 2001 From: Bradley Dice Date: Thu, 17 Sep 2020 03:06:41 -0500 Subject: DOC: Fix syntax errors in docstrings for versionchanged, versionadded (#17338) * DOC: Fix typos in versionchanged. --- numpy/core/multiarray.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'numpy/core/multiarray.py') diff --git a/numpy/core/multiarray.py b/numpy/core/multiarray.py index 225c9554c..540d1ea9b 100644 --- a/numpy/core/multiarray.py +++ b/numpy/core/multiarray.py @@ -163,12 +163,12 @@ def concatenate(arrays, axis=None, out=None, *, dtype=None, casting=None): If provided, the destination array will have this dtype. Cannot be provided together with `out`. - ..versionadded:: 1.20.0 + .. versionadded:: 1.20.0 casting : {'no', 'equiv', 'safe', 'same_kind', 'unsafe'}, optional Controls what kind of data casting may occur. Defaults to 'same_kind'. - ..versionadded:: 1.20.0 + .. versionadded:: 1.20.0 Returns ------- -- cgit v1.2.1 From 57adb4bb6a8eb46fed597d4a781e47bcb86ebe11 Mon Sep 17 00:00:00 2001 From: Bas van Beek <43369155+BvB93@users.noreply.github.com> Date: Thu, 1 Oct 2020 18:23:53 +0200 Subject: DOC: Fix a parameter type in the `putmask` docs (#17412) --- numpy/core/multiarray.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'numpy/core/multiarray.py') diff --git a/numpy/core/multiarray.py b/numpy/core/multiarray.py index 540d1ea9b..6b335f1a6 100644 --- a/numpy/core/multiarray.py +++ b/numpy/core/multiarray.py @@ -1100,7 +1100,7 @@ def putmask(a, mask, values): Parameters ---------- - a : array_like + a : ndarray Target array. mask : array_like Boolean mask array. It has to be the same shape as `a`. -- cgit v1.2.1 From 75927fcd2fe2613daa372638a8539dea4c1b29be Mon Sep 17 00:00:00 2001 From: andryandrew Date: Tue, 20 Oct 2020 16:02:17 +0200 Subject: DOC: Typo in lexsort docstring ...it's rows... --> ...its rows... --- numpy/core/multiarray.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'numpy/core/multiarray.py') diff --git a/numpy/core/multiarray.py b/numpy/core/multiarray.py index 6b335f1a6..d293700f2 100644 --- a/numpy/core/multiarray.py +++ b/numpy/core/multiarray.py @@ -406,7 +406,7 @@ def lexsort(keys, axis=None): for the primary sort order, the second-to-last key for the secondary sort order, and so on. The keys argument must be a sequence of objects that can be converted to arrays of the same shape. If a 2D array is provided - for the keys argument, it's rows are interpreted as the sorting keys and + for the keys argument, its rows are interpreted as the sorting keys and sorting is according to the last row, second last row etc. Parameters -- cgit v1.2.1 From 81e363da7a59ebccf3d583fb77dacb959cf6fa9a Mon Sep 17 00:00:00 2001 From: serge-sans-paille Date: Sat, 21 Nov 2020 07:41:43 +0100 Subject: Fix copy-paste typo in empty_like documentation. --- numpy/core/multiarray.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'numpy/core/multiarray.py') diff --git a/numpy/core/multiarray.py b/numpy/core/multiarray.py index d293700f2..4dd07ca4b 100644 --- a/numpy/core/multiarray.py +++ b/numpy/core/multiarray.py @@ -97,7 +97,7 @@ def empty_like(prototype, dtype=None, order=None, subok=None, shape=None): .. versionadded:: 1.6.0 subok : bool, optional. If True, then the newly created array will use the sub-class - type of 'a', otherwise it will be a base-class array. Defaults + type of `prototype`, otherwise it will be a base-class array. Defaults to True. shape : int or sequence of ints, optional. Overrides the shape of the result. If order='K' and the number of -- cgit v1.2.1 From 254836c570b96b2bb46c414fcf786ee649481670 Mon Sep 17 00:00:00 2001 From: serge-sans-paille Date: Sat, 21 Nov 2020 07:43:11 +0100 Subject: Harmonize quoting in (ones/fill/zeros/empty)_like documentation --- numpy/core/multiarray.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'numpy/core/multiarray.py') diff --git a/numpy/core/multiarray.py b/numpy/core/multiarray.py index 4dd07ca4b..f311fad8d 100644 --- a/numpy/core/multiarray.py +++ b/numpy/core/multiarray.py @@ -90,8 +90,8 @@ def empty_like(prototype, dtype=None, order=None, subok=None, shape=None): .. versionadded:: 1.6.0 order : {'C', 'F', 'A', or 'K'}, optional Overrides the memory layout of the result. 'C' means C-order, - 'F' means F-order, 'A' means 'F' if ``prototype`` is Fortran - contiguous, 'C' otherwise. 'K' means match the layout of ``prototype`` + 'F' means F-order, 'A' means 'F' if `prototype` is Fortran + contiguous, 'C' otherwise. 'K' means match the layout of `prototype` as closely as possible. .. versionadded:: 1.6.0 -- cgit v1.2.1 From d54e2dcc17e0f0a8702d4b0eb4ac30a5c927a056 Mon Sep 17 00:00:00 2001 From: Sebastian Berg Date: Wed, 2 Dec 2020 20:22:00 -0600 Subject: DEP: Finalize unravel_index `dims` alias for `shape` keyword The argument was renamed to `shape` and deprecated since NumPy 1.16, so the deprecation can now be finalized. --- numpy/core/multiarray.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'numpy/core/multiarray.py') diff --git a/numpy/core/multiarray.py b/numpy/core/multiarray.py index f311fad8d..f736973de 100644 --- a/numpy/core/multiarray.py +++ b/numpy/core/multiarray.py @@ -999,7 +999,7 @@ def ravel_multi_index(multi_index, dims, mode=None, order=None): @array_function_from_c_func_and_dispatcher(_multiarray_umath.unravel_index) -def unravel_index(indices, shape=None, order=None, dims=None): +def unravel_index(indices, shape=None, order=None): """ unravel_index(indices, shape, order='C') @@ -1045,9 +1045,6 @@ def unravel_index(indices, shape=None, order=None, dims=None): (3, 1, 4, 1) """ - if dims is not None: - warnings.warn("'shape' argument should be used instead of 'dims'", - DeprecationWarning, stacklevel=3) return (indices,) -- cgit v1.2.1