`chunks` needs to be passed to `to_multiscale` otherwise it's ignored
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 394
- Forks
- 95
- Avg merge
- 4d 3h
- Merged PRs (30d)
- 7
Description
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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
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.
Assessment
- Tech stack
- python
- Domain
- data
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 72/100