From 9f5c7d48a8f3938963a54259535dd644acfec137 Mon Sep 17 00:00:00 2001 From: Davis Vann Bennett Date: Fri, 9 Oct 2026 12:09:08 +0200 Subject: [PATCH] test(dtype): cover unicode fields in the structured default scalar test #4495 also changed the default of `U` fields in structured dtypes from "0" to "". Add `U4` to the regression test and name string fields in the changelog entry. Assisted-by: ClaudeCode:claude-opus-5-5 --- changes/4495.bugfix.md | 2 +- tests/test_dtype/test_npy/test_structured.py | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/changes/4495.bugfix.md b/changes/4495.bugfix.md index e95e5badda..ff9e45e1c2 100644 --- a/changes/4495.bugfix.md +++ b/changes/4495.bugfix.md @@ -1 +1 @@ -Structured data types now default byte-string (`S`) and raw-bytes (`V`) fields to zero bytes. Before, an array with a raw-bytes field failed to create without an explicit fill value, and byte-string fields defaulted to `b"0"`. +Structured data types now default string (`S`, `U`) and raw-bytes (`V`) fields to zero bytes. Before, an array with a raw-bytes field failed to create without an explicit fill value, and string fields defaulted to `"0"`. diff --git a/tests/test_dtype/test_npy/test_structured.py b/tests/test_dtype/test_npy/test_structured.py index e1920012b2..ac5c8701c6 100644 --- a/tests/test_dtype/test_npy/test_structured.py +++ b/tests/test_dtype/test_npy/test_structured.py @@ -394,10 +394,11 @@ def test_subarray_structured_dtype_raises() -> None: Struct.from_native_dtype(dtype) -@pytest.mark.parametrize("field_dtype", ["S4", "V4"]) +@pytest.mark.parametrize("field_dtype", ["S4", "U4", "V4"]) def test_default_scalar_bytes_field_is_zero(field_dtype: str) -> None: """ - The default scalar of a bytes field is zero bytes, as for the same dtype outside a struct. + The default scalar of a string or bytes field is zero bytes, as for the same dtype outside + a struct. """ dtype = np.dtype([("a", field_dtype), ("b", "