matplotlib / matplotlib/ipympl

Using ipympl logic inside python shell or ipython?

オープン
#68 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

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

主要言語
Jupyter Notebook
スター
1.7k
フォーク
234
PR マージ指標
30日以内にマージされた PR はありません

説明

I have a class that inherits from the `ipywidgets.widgets.VBox` and adds a `figure.canvas` instance of a matplotlib figure to its children like so:

```python
import matplotlib.pyplot as plt
from ipywidgets import widgets

plt.ioff()

class MyVis(widgets.VBox):
def __init__(self):
super().__init__()
self.fig = plt.figure()
self.children = [self.fig.canvas]

m = MyVis()
```

This works fine when I use this class within jupyter notebooks using the `%matplotlib widget` magic before executing the above code.
When executed within ipython I get
`TraitError: Element of the 'children' trait of a MyVis instance must be a Widget, but a value of was specified.`
since of course `ipympl` and its magic are not active.

Since I also want to have unit-tests for this class (and others that make use of this class) using `pytest`, it would be nice to get around this problem.
Can I enable the `ipympl` way of handling figures somehow in the python shell (similar to using the `%matplotlib widget` magic in the notebook) that would allow my tests to run?

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

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

はじめの一歩

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

調査の方向性

MyVis の例から始めて、IPython で TraitError を再現し、その後、`%matplotlib widget` マジックを使用するノートブックのセットアップと比較します。matplotlib の canvas がどのように選択されているかを確認し、pytest のテストケースが Jupyter 外で互換性のある widget canvas を使用できるようにするテストセットアップを特定します。クラスを Tk canvas エラーなしでインスタンス化してテストできれば完了です。

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

評価

技術スタック
jupyter, python
領域
backend, testing
issue の種類
機能追加
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
28/100

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

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