Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

`chunks` needs to be passed to `to_multiscale` otherwise it's ignored

Open Beginner friendly
#421 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
72/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
python
Domain
data

Research direction

Start by tracing to_multiscale() and its calls from Image2DModel and Image3DModel when scale_factors is a list. Check the Dask-array and xarray.DataArray paths, then verify that existing chunks are passed through instead of replaced by defaults. Done means explicitly chunked input retains its chunks without requiring chunks on Image2DModel.parse().

Written by the indexing model from the issue text.

Description

needs: triage priority: low

Super easy fix.

Problem

The function to_multiscale(), which is called by Image2DModel and Image3DModel when scale_factors is a list, calls this code:

    # IPFS and visualization friendly default chunks
    if "z" in image.dims:
        default_chunks = 64
    else:
        default_chunks = 256
    default_chunks = {d: default_chunks for d in image.dims}
    if "t" in image.dims:
        default_chunks["t"] = 1
    out_chunks = chunks
    if out_chunks is None:
        out_chunks = default_chunks

This means that if some chunks were already set for the data passed to the model, as in this case

    # data = da.ones((3, 32768, 32768), chunks=(1, 4096, 4096))
    chunks= (1, 4096, 4096)
    data = RNG.random((3, 32768, 32768), chunks=chunks)
    xdata = DataArray(data, dims=("c", "y", "x"))

    ##
    im = Image2DModel.parse(
        xdata,
        scale_factors=[2, 2, 2],
        # chunks=chunks
    )

They are rechunked, unless we pass chunk explicitly to Image2DModel.parse().

Solution

If the data has already chunks, pass them to to_multiscale(). This needs to be done when the data with a Dask array or an xarray DataArray.

Dominant language
Python
Stars
394
Forks
95
Avg merge
3d 9h
Merged PRs (30d)
5

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from scverse/spatialdata

All issues in scverse/spatialdata

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.