8000 BUG: Fix TestStringDiscovery float casting warning on FreeBSD by abhishek-iitmadras · Pull Request #28331 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

BUG: Fix TestStringDiscovery float casting warning on FreeBSD #28331

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 3 commits into from
Closed
Changes from 1 commit
Commits
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
Next Next commit
fix freebsd test failure
  • Loading branch information
abhishek-iitmadras committed Feb 15, 2025
commit 8fa17c1c70edcf3eb0536d6d1c0ebf733bbcc7b2
8 changes: 7 additions & 1 deletion numpy/_core/tests/test_array_coercion.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,14 +170,20 @@ def test_basic_stringlength(self, obj):
# The DType class is accepted by `.astype()`
assert arr.astype(type(np.dtype("S"))).dtype == expected

# Suppress known RuntimeWarning that occurs specifically on FreeBSD when
# casting float objects to string dtype in nested arrays. This warning does not
# affect the actual string length determination being tested.
# See https://github.com/numpy/numpy/issues/28329
@pytest.mark.filterwarnings("ignore:invalid value encountered in cast:RuntimeWarning")
@pytest.mark.parametrize("obj",
[object(), 1.2, 10**43, None, "string"],
ids=["object", "1.2", "10**43", "None", "string"])
def test_nested_arrays_stringlength(self, obj):
length = len(str(obj))
expected = np.dtype(f"S{length}")
arr = np.array(obj, dtype="O")
assert np.array([arr, arr], dtype="S").dtype == expected
result = np.array([arr, arr], dtype="S").dtype
assert result == expected

@pytest.mark.parametrize("arraylike", arraylikes())
def test_unpack_first_level(self, arraylike):
Expand Down
Loading
0