ENH: pad: implement more padding modes
まだ誰も着手していません。
評価
調査の方向性
エントリポイント xpx.pad から始め、現在の定数モードのパスを NumPy のスライス代入実装 _arraypad_impl.py と比較します。期待されるエッジの挙動を確認するため、引用されている SciPy と scikit-image の呼び出し箇所を確認します。これらの使用例と一致する挙動で、汎用的かつ配列に依存しない mode="edge" のサポートを追加すれば完了です。
索引モデルが issue の本文から書いたものです。
説明
Currently, xpx.pad only implements mode="constant". However, mode="edge" is used, for example, in SciPy FFT and ndimage,
$ git grep -n mode=\'edge\'
scipy/fft/tests/test_real_transforms.py:40: y2 = xp.asarray(np.pad(np.asarray(y), pad, mode='edge'))
scipy/fft/tests/test_real_transforms.py:111: y2 = xp.asarray(np.pad(np.asarray(y), pad, mode='edge'))
scipy/ndimage/_interpolation.py:219: padded = np.pad(input, npad, mode='edge')
scipy/signal/_short_time_fft.py:1096: 'edge': dict(mode='edge'),
also scikit-image:
$ git grep -n mode=\'edge\'
doc/examples/registration/plot_opticalflow.py:42:image1_warp = warp(image1, np.array([row_coords + v, col_coords + u]), mode='edge')
src/skimage/exposure/_adapthist.py:172: map_array = np.pad(hist, [[1, 1] for _ in range(ndim)] + [[0, 0]], mode='edge')
src/skimage/filters/_fft_based.py:92: ``mode='edge'`` extension.
src/skimage/filters/_fft_based.py:155: image = np.pad(image, npad, mode='edge')
src/skimage/registration/_optical_flow.py:104: moving_image, _get_warp_points(grid, flow_current), mode='edge'
src/skimage/registration/_optical_flow.py:324: moving_image, _get_warp_points(grid, flow), mode='edge'
src/skimage/segmentation/_chan_vese.py:26: P = np.pad(phi, 1, mode='edge')
src/skimage/segmentation/_chan_vese.py:95: P = np.pad(phi, 1, mode='edge')
src/skimage/segmentation/boundaries.py:37: windows = view_as_windows(np.pad(label_img_expanded, 1, mode='edge'), (3,) * ndim)
tests/skimage/registration/test_ilk.py:34: image1 = warp(image0, grid - gt_flow, mode='edge')
tests/skimage/registration/test_tvl1.py:34: image1 = warp(image0, grid - gt_flow, mode='edge')
tests/skimage/transform/test_warps.py:568: x, out_size, order=1, mode='edge', anti_aliasing=True, anti_aliasing_sigma=sigma
A generic, array-agnostic edge mode seems doable, since the numpy's version is pretty much all slice assignments,
https://github.com/numpy/numpy/blob/main/numpy/lib/_arraypad_impl.py#L870-L874
Many array libraries implement it natively: jax.numpy.pad, cupy.pad, even dask. An odd one out is pytorch, which only has an equivalent functionality in torchvision IIUC, so a pytorch version could probably share the padding code with a "generic" version.
- 主要言語
- Python
- スター
- 33
- フォーク
- 32
- 平均マージ
- 5時間 58分
- マージ済み PR(30日)
- 47
コントリビューションガイド
このリポジトリのコントリビューションガイドは索引されていません
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
data-apis/array-api-extra のほかの issue
-
enhancement new function
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
data-apis/array-api-extra#992 · コメント 1 件 ·
-
testing
難易度 3/5 1〜2日 初心者へのやさしさ 55/100
data-apis/array-api-extra#901 · コメント 3 件 ·
-
testing upstream issue
難易度 3/5 1〜2日 初心者へのやさしさ 45/100
data-apis/array-api-extra#900 · コメント 8 件 ·
-
blocked testing xpx.testing
難易度 5/5 1週間以上 初心者へのやさしさ 30/100
data-apis/array-api-extra#833 · コメント 1 件 · リアクション 1 件 ·
-
CI static typing
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
data-apis/array-api-extra#696 ·
data-apis/array-api-extra の issue をすべて見る
似ている issue
-
bug confirmed issue
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
open-webui/open-webui#30750 · コメント 1 件 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
-
enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
OpenwaterHealth/openmotion-bloodflow-app#604 · コメント 1 件 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
-
good first issue
難易度 1/5 1時間未満 初心者へのやさしさ 90/100