8000 Maintenance/1.21.x by helizaga · Pull Request #19333 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

Maintenance/1.21.x #19333

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 76 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
76 commits
Select commit Hold shift + click to select a range
8dc7689
Fix compile-time test of POPCNT
cmichal2 May 23, 2021
52d5fe1
Change fix of cpu_popcnt.c to use _mm_popcnt_u64/_mm_popcnt_u32 on GCC
cmichal2 May 23, 2021
3c84e9a
BUG: Fix test_numpy_version.
charris May 23, 2021
32b0261
Merge pull request #19074 from charris/backport-19071
charris May 23, 2021
ad021d3
Merge pull request #19075 from charris/fix-version-problem
charris May 23, 2021
b167abf
MAINT: Update cversions.
charris May 22, 2021
e6ce434
MAINT: Update mailmap.
charris May 23, 2021
11c7008
DOC: Create 1.21.0-changelog.rst
charris May 13, 2021
86a4dd0
DOC: Create 1.21.0 release note
charris May 22, 2021
5cbc580
Merge pull request #19073 from charris/prepare-1.21.0-release
charris May 23, 2021
106088d
BUG: Fixed an issue wherein `_GenericAlias.__getitem__` would raise f…
May 25, 2021
2ed1941
MAINT: Change the variance of the `npt.ArrayLike` to covariant
May 25, 2021
080faad
Merge pull request #19094 from BvB93/generic-alias-bug2
charris May 25, 2021
c3eb82a
BUG: Linter should on run on pull requests.
charris May 24, 2021
25b7d83
Merge pull request #19100 from charris/fix-linter-run-condition
charris May 26, 2021
9b29742
BUG: Fix setup.py to work in maintenance branches.
charris May 25, 2021
a6e0503
Merge pull request #19120 from charris/fix-numpy-version
charris May 28, 2021
264cc43
expose `short_version` as previously in version.py
kif May 31, 2021
e297b3d
BUG: re-introduce short-version as it was
kif May 31, 2021
10f444a
TST: fix pylint
kif May 31, 2021
8cd38bb
TST Fix typo
kif May 31, 2021
a959408
TST fix comment of assert+indentation
kif May 31, 2021
1591e61
Merge pull request #19144 from charris/backport-19142
charris May 31, 2021
334b7cd
API: Delay string and number promotion deprecation/future warning
seberg Jun 4, 2021
95b0352
Merge pull request #19175 from charris/backport-19170
charris Jun 5, 2021
838aae0
BUG, SIMD: Fix detect host/native CPU features on ICC during compile-…
seiko2plus May 25, 2021
e5d2624
Set c99 to intel icc compiler so numpy will build
i-shenl Mar 9, 2021
e3fce2b
Merge pull request #19178 from charris/backport-19098
charris Jun 6, 2021
5e459ce
Merge pull request #19180 from charris/backport-19177
charris Jun 6, 2021
bbdc753
NEP: Accept NEP 35 as final
seberg Jun 7, 2021
82622df
MAINT,BUG: Adapt `castingimpl.casting` to denote a minimal level
seberg Jun 5, 2021
787ee70
Merge pull request #19193 from charris/backport-19188
charris Jun 7, 2021
9fa3b04
Merge pull request #19194 from charris/backport-19174
charris Jun 7, 2021
5567fa9
DOC: Prepare for NumPy 1.20.0rc2 release.
charris Jun 4, 2021
e40a0b2
Merge pull request #19197 from charris/prepare-for-1.21.0rc2
charris Jun 8, 2021
4d1442a
MAINT: Add annotations for the missing `period` parameter to `np.unwrap`
Jun 10, 2021
cb6370e
Merge pull request #19213 from BvB93/unwrap-backport
charris Jun 10, 2021
7a29f54
MAINT: Add `complex` as allowed type for the `np.complexfloating` con…
BvB93 Jun 10, 2021
e9b8f0c
Merge pull request #19219 from BvB93/complex-backport
charris Jun 10, 2021
2def753
TST: Ignore exp FP exceptions test for glibc ver < 2.17
r-devulap Jun 9, 2021
45a322c
BUG: Do not use bare except
r-devulap Jun 9, 2021
9ad1ccb
TST: Use conditional xfail
r-devulap Jun 11, 2021
58805d7
TST: 2 blank lines after class def
r-devulap Jun 11, 2021
1342b96
TST: Getting rid of print
r-devulap Jun 12, 2021
a218e53
Merge pull request #19233 from charris/backport-19209
charris Jun 13, 2021
2aab9c8
MAINT: replace imgmath with mathjax for docs (#19036)
melissawm May 27, 2021
1befa1b
Fix out-of-bounds array access in convert_datetime_divisor_to_multipl…
hawkinsp Jun 9, 2021
d336c26
ENH: support major version larger than 9 in numpy.lib.NumpyVersion
kmaehashi Jun 10, 2021
34c7db0
DOC: fix typo
kmaehashi Jun 10, 2021
8171b01
Merge pull request #19238 from charris/backport-19036
charris Jun 13, 2021
5da37d5
Merge pull request #19240 from charris/backport-19214
charris Jun 13, 2021
a070e5d
Merge pull request #19239 from charris/backport-19402
charris Jun 13, 2021
be642f5
DOC: fix duplicate navbar in development documentation index (#19264)
melissawm Jun 17, 2021
a831463
BUG: Remove TypeError on invalid dtypes comparison
ganesh-k13 Jun 12, 2021
7324532
TST: Check invalid dtypes comparison
ganesh-k13 Jun 12, 2021
5f86809
BUG: Return NotImplemented for unrecognized dtypes
ganesh-k13 Jun 15, 2021
98d88c6
TST: Check invalid dtypes for equality | Check TypeError for comparis…
ganesh-k13 Jun 15, 2021
d80e473
BUG: Removed typing for == and != in dtypes
ganesh-k13 Jun 15, 2021
143d45f
Merge pull request #19269 from charris/backport-19228
charris Jun 17, 2021
61127bb
Merge pull request #19268 from charris/backport-19264
charris Jun 17, 2021
fa5754e
BUG: Add missing DECREF in new path
seberg Jun 18, 2021
7d25b81
BUG: Fix refcount leak in ResultType
seberg Jun 18, 2021
032fca5
Merge pull request #19280 from charris/backport-19277
charris Jun 19, 2021
07d7e72
MAINT: Remove accidentally created directory.
charris Jun 19, 2021
493b64b
MAINT: Update 1.21.0-changelog.rst
charris Jun 19, 2021
34aebc2
MAINT: Update 1.21.0-notes.rst
charris Jun 19, 2021
b235f9e
Merge pull request #19283 from charris/prepare-1.21.0-release
charris Jun 19, 2021
1cfefdf
REL: prepare 1.21.x for further development
charris Jun 22, 2021
4ebcc2b
REV,BUG: Replace `NotImplemented` with `typing.Any`
BvB93 Jun 23, 2021
209cca9
Merge pull request #19311 from BvB93/notimplemented
charris Jun 23, 2021
cd33912
MAINT: Fixed an issue with the return-dtype of `ndarray.real` and `imag
Jun 19, 2021
c532dcd
Merge pull request #19324 from BvB93/real_imag
charris Jun 24, 2021
7d397c2
MAINT: Replace `"dtype[Any]"` with `dtype` in the definiton of `npt.A…
BvB93 Jun 24, 2021
90e7ff1
TST: Test that the `numpy.typing` public API works in combination wit…
BvB93 Jun 24, 2021
c433e54
MAINT: Add a subscriptable runtime-only placeholder for `_SupportsDType`
BvB93 Jun 24, 2021
0e0d490
Merge pull request #19330 from BvB93/runtime
charris Jun 24, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
API: Delay string and number promotion deprecation/future warning
Unfortunately, this seems to cause some pain in pandas at least
to circumvent the warning.

Delaying may complicate the creation of ufuncs for strings, but
otherwise should not be a big problem.  We have to make sure that
we can reimplement the change quickly though, it is an important
change in my opinion.
  • Loading branch information
seberg authored and charris committed Jun 5, 2021
commit 334b7cd7bdcebbeb75e2e45b4aa55a8b22176832
45 changes: 20 additions & 25 deletions doc/source/release/1.21.0-notes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -121,40 +121,35 @@ The methods in question are:
(`gh-19031 <https://github.com/numpy/numpy/pull/19031>`__)


Future Changes
==============
Expired deprecations
====================

* The ``shape`` argument `numpy.unravel_index` cannot be passed
as ``dims`` keyword argument anymore. (Was deprecated in NumPy 1.16.)

Promotion of strings with numbers and bools will be deprecated
--------------------------------------------------------------
Any promotion of numbers and strings is deprecated and will
give a ``FutureWarning`` the main affected functionalities
are:
(`gh-17900 <https://github.com/numpy/numpy/pull/17900>`__)

* `~numpy.promote_types` and `~numpy.result_type` which will raise
an error in this case in the future.
* `~numpy.concatenate` will raise an error when concatenating a string
and numeric array. You can use ``dtype="S"`` to explicitly request
a string result.
* `~numpy.array` and related functions will start returning ``object``
arrays because these functions use ``object`` as a fallback when
no common dtype can be found. However, it may happen that future
releases of NumPy will generally error in these cases.
* The function ``PyUFunc_GenericFunction`` has been disabled.
It was deprecated in NumPy 1.19. Users should call the ufunc
directly using the Python API.

This will mainly affect code such as::
(`gh-18697 <https://github.com/numpy/numpy/pull/18697>`__)

np.asarray(['string', 0])
* The function ``PyUFunc_SetUsesArraysAsData`` has been disabled.
It was deprecated in NumPy 1.19.

and::
(`gh-18697 <https://github.com/numpy/numpy/pull/18697>`__)

np.concatenate((['string'], [0]))
Remove deprecated ``PolyBase`` and unused ``PolyError`` and ``PolyDomainError``
-------------------------------------------------------------------------------

in both cases adding ``dtype="U"`` or ``dtype="S"`` will give the
previous (string) result, while ``dtype=object`` will ensure an array with
object dtype is returned.
The class ``PolyBase`` has been removed (deprecated in numpy 1.9.0). Please use
the abstract ``ABCPolyBase`` class instead.

Comparisons, universal functions, and casting are not affected by this.
Furthermore, the unused ``PolyError`` and ``PolyDomainError`` exceptions are
removed from the `numpy.polynomial`.

(`gh-18116 <https://github.com/numpy/numpy/pull/18116>`__)
(`gh-18963 <https://github.com/numpy/numpy/pull/18963>`__)


Compatibility notes
Expand Down
13 changes: 0 additions & 13 deletions numpy/core/src/multiarray/dtypemeta.c
Original file line number Diff line number Diff line change
Expand Up @@ -415,19 +415,6 @@ string_unicode_common_dtype(PyArray_DTypeMeta *cls, PyArray_DTypeMeta *other)
Py_INCREF(Py_NotImplemented);
return (PyArray_DTypeMeta *)Py_NotImplemented;
}
if (other->type_num != NPY_STRING && other->type_num != NPY_UNICODE) {
/* Deprecated 2020-12-19, NumPy 1.21. */
if (DEPRECATE_FUTUREWARNING(
"Promotion of numbers and bools to strings is deprecated. "
"In the future, code such as `np.concatenate((['string'], [0]))` "
"will raise an error, while `np.asarray(['string', 0])` will "
"return an array with `dtype=object`. To avoid the warning "
"while retaining a string result use `dtype='U'` (or 'S'). "
"To get an array of Python objects use `dtype=object`. "
"(Warning added in NumPy 1.21)") < 0) {
return NULL;
}
}
/*
* The builtin types are ordered by complexity (aside from object) here.
* Arguably, we should not consider numbers and strings "common", but
Expand Down
35 changes: 0 additions & 35 deletions numpy/core/tests/test_deprecations.py
Original file line number Diff line number Diff line change
Expand Up @@ -1105,41 +1105,6 @@ def check_parametrize(base, power, expected):
self.assert_deprecated(_test_parametrize)


class TestStringPromotion(_DeprecationTestCase):
# Deprecated 2020-12-19, NumPy 1.21
warning_cls = FutureWarning
message = "Promotion of numbers and bools to strings is deprecated."

@pytest.mark.parametrize("dtype", "?bhilqpBHILQPefdgFDG")
@pytest.mark.parametrize("string_dt", ["S", "U"])
def test_deprecated(self, dtype, string_dt):
self.assert_deprecated(lambda: np.promote_types(dtype, string_dt))

# concatenate has to be able to promote to find the result dtype:
arr1 = np.ones(3, dtype=dtype)
arr2 = np.ones(3, dtype=string_dt)
self.assert_deprecated(lambda: np.concatenate((arr1, arr2), axis=0))
self.assert_deprecated(lambda: np.concatenate((arr1, arr2), axis=None))

self.assert_deprecated(lambda: np.array([arr1[0], arr2[0]]))

@pytest.mark.parametrize("dtype", "?bhilqpBHILQPefdgFDG")
@pytest.mark.parametrize("string_dt", ["S", "U"])
def test_not_deprecated(self, dtype, string_dt):
# The ufunc type resolvers run into this, but giving a futurewarning
# here is unnecessary (it ends up as an error anyway), so test that
# no warning is given:
arr1 = np.ones(3, dtype=dtype)
arr2 = np.ones(3, dtype=string_dt)

# Adding two arrays uses result_type normally, which would fail:
with pytest.raises(TypeError):
self.assert_not_deprecated(lambda: arr1 + arr2)
# np.equal uses a different type resolver:
with pytest.raises(TypeError):
self.assert_not_deprecated(lambda: np.equal(arr1, arr2))


class TestSingleElementSignature(_DeprecationTestCase):
# Deprecated 2021-04-01, NumPy 1.21
message = r"The use of a length 1"
Expand Down
6 changes: 2 additions & 4 deletions numpy/core/tests/test_half.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,8 @@ def test_half_conversions(self):
def test_half_conversion_to_string(self, string_dt):
# Currently uses S/U32 (which is sufficient for float32)
expected_dt = np.dtype(f"{string_dt}32")
with pytest.warns(FutureWarning):
assert np.promote_types(np.float16, string_dt) == expected_dt
with pytest.warns(FutureWarning):
assert np.promote_types(string_dt, np.float16) == expected_dt
assert np.promote_types(np.float16, string_dt) == expected_dt
assert np.promote_types(string_dt, np.float16) == expected_dt

arr = np.ones(3, dtype=np.float16).astype(string_dt)
assert arr.dtype == expected_dt
Expand Down
67 changes: 30 additions & 37 deletions numpy/core/tests/test_numeric.py

Original file line number Diff line number Diff line change
Expand Up @@ -848,12 +848,10 @@ def test_promote_types_endian(self):
assert_equal(np.promote_types('<i8', '<i8'), np.dtype('i8'))
assert_equal(np.promote_types('>i8', '>i8'), np.dtype('i8'))

with pytest.warns(FutureWarning,
match="Promotion of numbers and bools to strings"):
assert_equal(np.promote_types('>i8', '>U16'), np.dtype('U21'))
assert_equal(np.promote_types('<i8', '<U16'), np.dtype('U21'))
assert_equal(np.promote_types('>U16', '>i8'), np.dtype('U21'))
assert_equal(np.promote_types('<U16', '<i8'), np.dtype('U21'))
assert_equal(np.promote_types('>i8', '>U16'), np.dtype('U21'))
assert_equal(np.promote_types('<i8', '<U16'), np.dtype('U21'))
assert_equal(np.promote_types('>U16', '>i8'), np.dtype('U21'))
assert_equal(np.promote_types('<U16', '<i8'), np.dtype('U21'))

assert_equal(np.promote_types('<S5', '<U8'), np.dtype('U8'))
assert_equal(np.promote_types('>S5', '>U8'), np.dtype('U8'))
Expand Down Expand Up @@ -901,37 +899,32 @@ def test_promote_types_strings(self, swap, string_dtype):

S = string_dtype
with pytest.warns(FutureWarning,
match="Promotion of numbers and bools to strings") as record:
# Promote numeric with unsized string:
assert_equal(promote_types('bool', S), np.dtype(S+'5'))
assert_equal(promote_types('b', S), np.dtype(S+'4'))
assert_equal(promote_types('u1', S), np.dtype(S+'3'))
assert_equal(promote_types('u2', S), np.dtype(S+'5'))
assert_equal(promote_types('u4', S), np.dtype(S+'10'))
assert_equal(promote_types('u8', S), np.dtype(S+'20'))
assert_equal(promote_types('i1', S), np.dtype(S+'4'))
assert_equal(promote_types('i2', S), np.dtype(S+'6'))
assert_equal(promote_types('i4', S), np.dtype(S+'11'))
assert_equal(promote_types('i8', S), np.dtype(S+'21'))
# Promote numeric with sized string:
assert_equal(promote_types('bool', S+'1'), np.dtype(S+'5'))
assert_equal(promote_types('bool', S+'30'), np.dtype(S+'30'))
assert_equal(promote_types('b', S+'1'), np.dtype(S+'4'))
assert_equal(promote_types('b', S+'30'), np.dtype(S+'30'))
assert_equal(promote_types('u1', S+'1'), np.dtype(S+'3'))
assert_equal(promote_types('u1', S+'30'), np.dtype(S+'30'))
assert_equal(promote_types('u2', S+'1'), np.dtype(S+'5'))
assert_equal(promote_types('u2', S+'30'), np.dtype(S+'30'))
assert_equal(promote_types('u4', S+'1'), np.dtype(S+'10'))
assert_equal(promote_types('u4', S+'30'), np.dtype(S+'30'))
assert_equal(promote_types('u8', S+'1'), np.dtype(S+'20'))
assert_equal(promote_types('u8', S+'30'), np.dtype(S+'30'))
# Promote with object:
assert_equal(promote_types('O', S+'30'), np.dtype('O'))

assert len(record) == 22 # each string promotion gave one warning

# Promote numeric with unsized string:
assert_equal(promote_types('bool', S), np.dtype(S+'5'))
assert_equal(promote_types('b', S), np.dtype(S+'4'))
assert_equal(promote_types('u1', S), np.dtype(S+'3'))
assert_equal(promote_types('u2', S), np.dtype(S+'5'))
assert_equal(promote_types('u4', S), np.dtype(S+'10'))
assert_equal(promote_types('u8', S), np.dtype(S+'20'))
assert_equal(promote_types('i1', S), np.dtype(S+'4'))
assert_equal(promote_types('i2', S), np.dtype(S+'6'))
assert_equal(promote_types('i4', S), np.dtype(S+'11'))
assert_equal(promote_types('i8', S), np.dtype(S+'21'))
# Promote numeric with sized string:
assert_equal(promote_types('bool', S+'1'), np.dtype(S+'5'))
assert_equal(promote_types('bool', S+'30'), np.dtype(S+'30'))
assert_equal(promote_types('b', S+'1'), np.dtype(S+'4'))
assert_equal(promote_types('b', S+'30'), np.dtype(S+'30'))
assert_equal(promote_types('u1', S+'1'), np.dtype(S+'3'))
assert_equal(promote_types('u1', S+'30'), np.dtype(S+'30'))
assert_equal(promote_types('u2', S+'1'), np.dtype(S+'5'))
assert_equal(promote_types('u2', S+'30'), np.dtype(S+'30'))
assert_equal(promote_types('u4', S+'1'), np.dtype(S+'10'))
assert_equal(promote_types('u4', S+'30'), np.dtype(S+'30'))
assert_equal(promote_types('u8', S+'1'), np.dtype(S+'20'))
assert_equal(promote_types('u8', S+'30'), np.dtype(S+'30'))
# Promote with object:
assert_equal(promote_types('O', S+'30'), np.dtype('O'))

@pytest.mark.parametrize(["dtype1", "dtype2"],
[[np.dtype("V6"), np.dtype("V10")],
Expand Down
4 changes: 1 addition & 3 deletions numpy/core/tests/test_regression.py
Original file line number Diff line number Diff line change
Expand Up @@ -782,9 +782,7 @@ def test_mem_string_arr(self):
# Ticket #514
s = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
t = []
with pytest.warns(FutureWarning,
match="Promotion of numbers and bools to strings"):
np.hstack((t, s))
np.hstack((t, s))

def test_arr_transpose(self):
# Ticket #516
Expand Down
3 changes: 1 addition & 2 deletions numpy/lib/tests/test_regression.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,7 @@ def test_mem_polymul(self):
def test_mem_string_concat(self):
# Ticket #469
x = np.array([])
with pytest.warns(FutureWarning):
np.append(x, 'asdasd\tasdasd')
np.append(x, 'asdasd\tasdasd')

def test_poly_div(self):
# Ticket #553
Expand Down
0