scverse / scverse/spatialdata

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

オープン 初心者向け
#421 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

needs: triage priority: low
主要言語
Python
スター
394
フォーク
95
平均マージ
4日 3時間
マージ済み PR(30日)
7

説明

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.

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

scale_factors がリストの場合に、まず to_multiscale() と Image2DModel および Image3DModel からのその呼び出しを追跡します。Dask-array と xarray.DataArray の経路を確認し、既存の chunks がデフォルト値で置き換えられず、そのまま渡されることを検証します。Image2DModel.parse() で chunks を要求しなくても、明示的に chunk 化された入力がその chunks を保持すれば完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
python
領域
data
issue の種類
バグ
難易度
2/5
見積もり時間
1〜3時間
活発さ
活発
明瞭さ
おおむね明確
初心者へのやさしさ
72/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。