Skip to content

default filters for v2 object dtype are wrong #2627

Closed

Description

@d-v-b

this example does not work in main:

def test_x() -> None:
    array = create(
        store={},
        path='foo',
        dtype='O',
        zarr_format=2,
        shape=(3,)
        )
    array[:] = np.array(['a', 'b', 'c'], dtype='O')

The problem is caused because zarr chooses the wrong default filters for O dtype arrays -- zarr chooses VlenBytes, when it should be choosing VlenUTF8. Since the structure of the default codecs is likely to change soon, the fix should probably be made in the context of #2463

cc @dcherian

Activity

  1. added
    bug
    on Jan 2, 2025
  2. dstansby commented on Jan 3, 2025

    @dstansby
    Contributor

    Seems pretty major, so I've added to the 3.0 milestone - we should at least document this as a known issue!

  3. added this to the 3.0.0 milestone on Jan 3, 2025
  4. d-v-b commented on Jan 4, 2025

    @d-v-b
    ContributorAuthor

    this is still broken on main. I can "fix" it by associating the dtype string O with the VlenUTF8 codec instead of VlenBytes, but that shouldn't work in general for O dtype arrays (and it breaks some tests).

    knowing little about how zarr encodes arbitrary python objects, I checked how this works in v2, and it seems that zarr.create(dtype='O') would error if an object_codec was not provided. Not sure we want to emulate that. The original bug report came from xarray's integration tests with zarr main; I can look into how those tests are calling zarr APIs exactly

  5. jhamman commented on Jan 8, 2025

    @jhamman
    Member

    I'm adding this to the known issues section in the v3 migration guide and marking it as After 3.0.0.

  6. modified the milestones: 3.0.0, After 3.0.0 on Jan 8, 2025
  7. removed this from the After 3.0.0 milestone on May 14, 2025
  8. d-v-b commented on Jul 7, 2026

    @d-v-b
    ContributorAuthor

    closing as completed. we don't accept the ambiguous identifier 'O' as a data type any more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions