You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by jo...@apache.org on 2023/06/01 07:00:48 UTC
[arrow] branch main updated: GH-35853: [Python] Fix deprecation warnings from NumPy NEP50 (#35854)
This is an automated email from the ASF dual-hosted git repository.
jorisvandenbossche pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow.git
The following commit(s) were added to refs/heads/main by this push:
new e07e22c558 GH-35853: [Python] Fix deprecation warnings from NumPy NEP50 (#35854)
e07e22c558 is described below
commit e07e22c5580af2a6ccd3664c69539c232b9422ed
Author: Dane Pitkin <48...@users.noreply.github.com>
AuthorDate: Thu Jun 1 03:00:34 2023 -0400
GH-35853: [Python] Fix deprecation warnings from NumPy NEP50 (#35854)
### Rationale for this change
Remove warnings from the pyarrow test suite (preventing them from eventually becoming errors).
### Are these changes tested?
Yes, verified no warnings are displayed.
### Are there any user-facing changes?
No.
* Closes: #35853
Authored-by: Dane Pitkin <da...@voltrondata.com>
Signed-off-by: Joris Van den Bossche <jo...@gmail.com>
---
python/pyarrow/tests/test_array.py | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/python/pyarrow/tests/test_array.py b/python/pyarrow/tests/test_array.py
index fe272151e8..65f69a9c0f 100644
--- a/python/pyarrow/tests/test_array.py
+++ b/python/pyarrow/tests/test_array.py
@@ -1414,16 +1414,19 @@ def test_chunked_array_data_warns():
def test_cast_integers_unsafe():
- # We let NumPy do the unsafe casting
+ # We let NumPy do the unsafe casting.
+ # Note that NEP50 in the NumPy spec no longer allows
+ # the np.array() constructor to pass the dtype directly
+ # if it results in an unsafe cast.
unsafe_cases = [
(np.array([50000], dtype='i4'), 'int32',
- np.array([50000], dtype='i2'), pa.int16()),
+ np.array([50000]).astype(dtype='i2'), pa.int16()),
(np.array([70000], dtype='i4'), 'int32',
- np.array([70000], dtype='u2'), pa.uint16()),
+ np.array([70000]).astype(dtype='u2'), pa.uint16()),
(np.array([-1], dtype='i4'), 'int32',
- np.array([-1], dtype='u2'), pa.uint16()),
+ np.array([-1]).astype(dtype='u2'), pa.uint16()),
(np.array([50000], dtype='u2'), pa.uint16(),
- np.array([50000], dtype='i2'), pa.int16())
+ np.array([50000]).astype(dtype='i2'), pa.int16())
]
for case in unsafe_cases: