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", "