Skip to content

np.dtypes.StringDType(na_object=None) doesn’t get preserved #3692

@flying-sheep

Description

@flying-sheep

Zarr version

3.1.5

Numcodecs version

0.16.5

Python Version

3.13

Operating System

Mac

Installation

uvx --with=zarr --with=numpy ipython

Description

Trying to store a numpy string array with na_object=np.nan fails, but storing one with

Steps to reproduce

# /// script
# requires-python = ">=3.11"
# dependencies = [
#   "zarr@git+https://github.com/zarr-developers/zarr-python.git@main",
# ]
# ///

import zarr

arr_str = np.array(["x", None], dtype=np.dtypes.StringDType(na_object=None))
print(arr_str)  # -> array(['x', None], dtype=StringDType(na_object=None))

g = zarr.open_group(store={})
g["arr_str"] = arr_str
print(g["arr_str"][:])  # -> array(['x', ''], dtype=StringDType())

Additional output

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugPotential issues with the zarr-python library

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions