Skip to content

Commit

Permalink
Don't assume a warning is thrown, since it varies by package/dependen…
Browse files Browse the repository at this point in the history
…cy versions
  • Loading branch information
danepitkin committed Aug 3, 2023
1 parent 9195826 commit 6db95f6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
8 changes: 3 additions & 5 deletions python/pyarrow/tests/test_pandas.py
Original file line number Diff line number Diff line change
Expand Up @@ -2913,11 +2913,9 @@ def test_strided_data_import(self):
'f4', 'f8']

for type_name in numeric_dtypes:
if type_name in ['u4', 'u8']:
# Casting np.float64 -> uint32 or uint64 throws a RuntimeWarning
with pytest.warns(RuntimeWarning):
cases.append(random_numbers.astype(type_name))
else:
# Casting np.float64 -> uint32 or uint64 throws a RuntimeWarning
with warnings.catch_warnings():
warnings.simplefilter("ignore")
cases.append(random_numbers.astype(type_name))

# strings
Expand Down
8 changes: 4 additions & 4 deletions python/pyarrow/tests/test_tensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import os
import sys
import pytest
import warnings
import weakref

import numpy as np
Expand Down Expand Up @@ -82,10 +83,9 @@ def test_tensor_base_object():
@pytest.mark.parametrize('dtype_str,arrow_type', tensor_type_pairs)
def test_tensor_numpy_roundtrip(dtype_str, arrow_type):
dtype = np.dtype(dtype_str)
if dtype in [np.uint32, np.uint64]:
# Casting np.float64 -> uint32 or uint64 throws a RuntimeWarning
data = (np.random.randint(0, 100, size=(10, 4))).astype(dtype)
else:
# Casting np.float64 -> uint32 or uint64 throws a RuntimeWarning
with warnings.catch_warnings():
warnings.simplefilter("ignore")
data = (100 * np.random.randn(10, 4)).astype(dtype)
tensor = pa.Tensor.from_numpy(data)
assert tensor.type == arrow_type
Expand Down

0 comments on commit 6db95f6

Please sign in to comment.