Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

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

未关闭 适合新手
#421 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
72/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
活跃
技术栈
python
领域
data

调研方向

首先跟踪当 scale_factors 为列表时,to_multiscale() 及其从 Image2DModel 和 Image3DModel 发起的调用。检查 Dask-array 和 xarray.DataArray 路径,然后验证现有 chunks 会被直接传递,而不是被默认值替换。完成的标准是:显式指定 chunks 的输入能够保留其 chunks,而无需在 Image2DModel.parse() 中要求提供 chunks。

由索引模型根据 Issue 内容生成。

描述

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.

主要语言
Python
星标
394
派生
95
平均合并
3 天 9 小时
30 天内合并 PR
5

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

scverse/spatialdata 的其他 Issue

查看 scverse/spatialdata 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。