Skip to content

CastValue endianness bug #3937

@LDeakin

Description

@LDeakin

Description

ValueError: Invalid endianness: None. Expected one of ('little', 'big') or None, but I'd expect it it to work.

Steps to reproduce

#!/usr/bin/env -S uv run
# /// script
# requires-python = ">=3.12"
# dependencies = [
#     # "cast-value-rs",
#     "numpy",
#     "zarr==3.2.0",
# ]
# ///

from __future__ import annotations

import tempfile
from pathlib import Path

import numpy as np
import zarr
from zarr.codecs import BytesCodec, CastValue


def main() -> None:
    with tempfile.TemporaryDirectory() as tmpdir:
        path = Path(tmpdir) / "cast_value_repro_invalid_endianness.zarr"
        array = zarr.create_array(
            path,
            shape=(4,),
            chunks=(4,),
            dtype="int8",
            fill_value=0,
            filters=[CastValue(data_type="int16")],
            serializer=BytesCodec(endian="little"),
            compressors=[],
            zarr_format=3,
            overwrite=True,
        )
        array[:] = np.asarray([0, 1, 2, 3], dtype=np.int8)
        _ = array[:]


if __name__ == "__main__":
    main()

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