Generalize pytest-mpl to support non-Matplotlib visual output
まだ誰も着手していません。
評価
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 初心者へのやさしさ
- 25/100
- issue の種類
- 機能追加
- 明瞭さ
- 説明が足りない
- 活発さ
- 停滞
- 技術スタック
- jupyter, playwright, python
- 領域
- testing-qa
調査の方向性
既存の pytest.mark.mpl_image_compare エントリーポイントと issue 内のサンプルテストから始め、返された Matplotlib の Figure がハッシュとギャラリー用にどのように変換されるかを追跡します。PIL.Image を含む、Matplotlib を使用しないサポート対象の戻り値の経路を定義し、画像比較、ハッシュ、ギャラリーが Matplotlib ラッパーなしでも引き続き動作することを確認します。
索引モデルが issue の本文から書いたものです。
説明
I am currently trying to use the Solara testing framework to try and do unit/regression testing of the rendering of Jupyter widgets, and I was wishing that I could just re-use all the pytest-mpl infrastructure to do figure hashes, galleries, etc. In a discussion with @Cadair we realised that it is possible, although a little ugly right now:
import ipywidgets as widgets
import matplotlib.pyplot as plt
import playwright.sync_api
import pytest
from IPython.display import display
from PIL import Image
@pytest.mark.mpl_image_compare(savefig_kwargs={"dpi": 100})
def test_scatter_solara(
tmp_path,
solara_test,
page_session: playwright.sync_api.Page,
assert_solara_snapshot,
):
from glue_jupyter import jglue
from IPython.display import display
app = jglue()
app.add_data(a={"x": [1, 2, 3], "y": [2, 3, 4]})
scatter = app.scatter2d(show=False)
display(scatter._layout)
button_sel = page_session.locator("text=No selection")
button_sel.wait_for()
screenshot = page_session.screenshot()
with open(tmp_path / "screenshot.png", "wb") as f:
f.write(screenshot)
image = Image.open(tmp_path / "screenshot.png")
size_x, size_y = image.size
fig = plt.figure(figsize=(size_x / 100, size_y / 100))
ax = fig.add_axes([0, 0, 1, 1])
ax.imshow(image)
plt.axis("off")
return fig
Basically one can in principle take any image output and show it in a Matplotlib figure. However this is a bit hacky, and what would be a lot nicer would be if we could generalize this plugin to allow for alternatives to what actually generates the images, with Matplotlib being just one (and given the plugin name the default) option.
To keep this simple, we could also simply allow the returned value from tests to be a PIL Image instance as this would already allow any arbitrary image generation in the tests.
Does anyone have any thoughts on this? Any reason to not at least allow PIL returns?
- 主要言語
- Python
- スター
- 274
- フォーク
- 53
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
matplotlib/pytest-mpl のほかの issue
-
難易度 4/5 3〜5日 初心者へのやさしさ 48/100
matplotlib/pytest-mpl#264 · コメント 2 件 · リアクション 1 件 ·
-
難易度 3/5 1〜2日 初心者へのやさしさ 35/100
matplotlib/pytest-mpl#263 · コメント 3 件 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 55/100
matplotlib/pytest-mpl#262 · コメント 6 件 ·
-
難易度 4/5 3〜5日 初心者へのやさしさ 45/100
matplotlib/pytest-mpl#261 · コメント 1 件 ·
-
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
matplotlib/pytest-mpl#257 · コメント 2 件 ·
matplotlib/pytest-mpl の issue をすべて見る
似ている issue
-
[Doc]: Feedback for `/zh-cn/v0.30.0/tutorials/models/Qwen3.6-35B-A3B.html`A3社区配置和基线不一致,社区配置也达不到基线オープンdocumentation
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
vllm-project/vllm-ascend#24429 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
simnJS/AnyPS5#735 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 67/100
nq-rdl/agent-extensions#623 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
vortex-data/vortex#12633 ·
メンテナーはふだん 1 日以内に返信
-
needs-triage
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
gke-labs/kube-agents#7955 ·
メンテナーはふだん 1 日以内に返信