Skip to content

The chunks parameter is ignored for DataArray models inheriting from RasterSchema #1030

@MSHelm

Description

@MSHelm

Hey everyone,

I wanted to read in an externally generated segmentation and parse it as a Label2DModel. In the harpy package they require identical chunks between the label and the values layer, therefore I wanted to pass in the same chunks into the label model. But it turns out that this parameter gets ignored entirely for a DataArray. I think the culprit is that it never gets passed to from_array:

elif isinstance(data, np.ndarray | DaskArray):
if not isinstance(data, DaskArray): # numpy -> dask
data = from_array(data)
if dims is None:

Repro:

import spatialdata as sd
import numpy as np

arr = np.random.rand(2048, 2048)
model = sd.models.Labels2DModel.parse(
    arr, 
    dims=("y", "x"), 
    transformations={"global": sd.transformations.Identity()},
    chunks={"x": 1024, "y": 1024 } # I also tried passing (1024, 1024) with same effect.
)

print(model.chunks)
# ((2048,), (2048,))

Maybe related to #81

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions