Skip to content

Adding Quantize filter to ds.to_zarr encoding does not work #3165

Open
@raphaeljolivet

Description

@raphaeljolivet

Zarr version

3.0.8

Numcodecs version

0.16.1

Python Version

3.12

Operating System

Linux

Installation

pip + venv

Description

I am struggling to add a Quantize filter before compression, with zarr v3.
I work with xarray (2025.6.1)

I get the following error :
TypeError: Expected a ArrayArrayCodec. Got <class 'numcodecs.quantize.Quantize'> instead.

Using from numcodecs.zarr3 import Quantize leads another error :
TypeError: Object of type type is not JSON serializable

What is the proper way to add filters to encoding with zarr V3 & *xarray ?

Steps to reproduce

from numcodecs import Quantize
import numpy as np

encoding={
   "var" : dict(filters=[Quantize(digits=2, dtype=np.float32)])
}
ds.to_zarr(..., encoding=encoding)

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