Skip to content

Commit 19e84dc

Browse files
authored
test(dtype): cover unicode fields in the structured default scalar test (#4496)
#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
1 parent 3d1a839 commit 19e84dc

2 files changed

Lines changed: 4 additions & 3 deletions

File tree

‎changes/4495.bugfix.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +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"`.
1+
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"`.

‎tests/test_dtype/test_npy/test_structured.py‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -394,10 +394,11 @@ def test_subarray_structured_dtype_raises() -> None:
394394
Struct.from_native_dtype(dtype)
395395

396396

397-
@pytest.mark.parametrize("field_dtype", ["S4", "V4"])
397+
@pytest.mark.parametrize("field_dtype", ["S4", "U4", "V4"])
398398
def test_default_scalar_bytes_field_is_zero(field_dtype: str) -> None:
399399
"""
400-
The default scalar of a bytes field is zero bytes, as for the same dtype outside a struct.
400+
The default scalar of a string or bytes field is zero bytes, as for the same dtype outside
401+
a struct.
401402
"""
402403
dtype = np.dtype([("a", field_dtype), ("b", "<f4")])
403404
assert Struct.from_native_dtype(dtype).default_scalar().tobytes() == bytes(dtype.itemsize)

0 commit comments

Comments
 (0)