matplotlib / matplotlib/ipympl

DeprecationWarning: Passing unrecognized arguments to super(Toolbar).__init__().

Aperta
#611 4 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Lingua principale
Jupyter Notebook
Stelle
1.7k
Fork
234
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

## Describe the issue

```
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
File ~/.miniforge/lib/python3.13/site-packages/traitlets/traitlets.py:1379, in HasTraits.__init__(self, *args, **kwargs)
1378 try:
-> [1379](https://file+.vscode-resource.vscode-cdn.net/home/firestar/NAOC/HVC-catalog/Test/~/.miniforge/lib/python3.13/site-packages/traitlets/traitlets.py:1379) super().__init__(*super_args, **super_kwargs)
1380 except TypeError as e:

TypeError: NavigationToolbar2WebAgg.__init__() missing 1 required positional argument: 'canvas'

During handling of the above exception, another exception occurred:

DeprecationWarning Traceback (most recent call last)
Cell In[24], [line 4](vscode-notebook-cell:?execution_count=24&line=4)
2 cluster_id = hvc_candidates[i]
3 moment_0_crop, extent, xc, yc, a, b, theta, area = cluster_params[i]
----> [4](vscode-notebook-cell:?execution_count=24&line=4) fig, ax = plt.subplots(1, 2, figsize=[10, 4])
5 im = ax[0].imshow(
6 moment_0_crop,
7 extent=extent,
(...) 10 interpolation="none",
11 )
12 cs = ax[0].contour(
13 moment_0_crop,
14 levels=[0.5 * np.max(moment_0_crop)],
(...) 18 linestyles="solid",
19 )

File ~/.miniforge/lib/python3.13/site-packages/matplotlib/pyplot.py:1776, in subplots(nrows, ncols, sharex, sharey, squeeze, width_ratios, height_ratios, subplot_kw, gridspec_kw, **fig_kw)
1621 def subplots(
1622 nrows: int = 1, ncols: int = 1, *,
1623 sharex: bool | Literal["none", "all", "row", "col"] = False,
(...) 1630 **fig_kw
1631 ) -> tuple[Figure, Any]:
1632 """
1633 Create a figure and a set of subplots.
1634
(...) 1774
1775 """
-> [1776](https://file+.vscode-resource.vscode-cdn.net/home/firestar/NAOC/HVC-catalog/Test/~/.miniforge/lib/python3.13/site-packages/matplotlib/pyplot.py:1776) fig = figure(**fig_kw)
1777 axs = fig.subplots(nrows=nrows, ncols=ncols, sharex=sharex, sharey=sharey,
1778 squeeze=squeeze, subplot_kw=subplot_kw,
1779 gridspec_kw=gridspec_kw, height_ratios=height_ratios,
1780 width_ratios=width_ratios)
1781 return fig, axs

File ~/.miniforge/lib/python3.13/site-packages/matplotlib/pyplot.py:1041, in figure(num, figsize, dpi, facecolor, edgecolor, frameon, FigureClass, clear, **kwargs)
1031 if len(allnums) == max_open_warning >= 1:
1032 _api.warn_external(
1033 f"More than {max_open_warning} figures have been opened. "
1034 f"Figures created through the pyplot interface "
(...) 1038 f"Consider using `matplotlib.pyplot.close()`.",
1039 RuntimeWarning)
-> [1041](https://file+.vscode-resource.vscode-cdn.net/home/firestar/NAOC/HVC-catalog/Test/~/.miniforge/lib/python3.13/site-packages/matplotlib/pyplot.py:1041) manager = new_figure_manager(
1042 num, figsize=figsize, dpi=dpi,
1043 facecolor=facecolor, edgecolor=edgecolor, frameon=frameon,
1044 FigureClass=FigureClass, **kwargs)
1045 fig = manager.canvas.figure
1046 if fig_label:

File ~/.miniforge/lib/python3.13/site-packages/matplotlib/pyplot.py:551, in new_figure_manager(*args, **kwargs)
549 """Create a new figure manager instance."""
550 _warn_if_gui_out_of_main_thread()
--> [551](https://file+.vscode-resource.vscode-cdn.net/home/firestar/NAOC/HVC-catalog/Test/~/.miniforge/lib/python3.13/site-packages/matplotlib/pyplot.py:551) return _get_backend_mod().new_figure_manager(*args, **kwargs)

File ~/.miniforge/lib/python3.13/site-packages/matplotlib/backend_bases.py:3504, in _Backend.new_figure_manager(cls, num, *args, **kwargs)
3502 fig_cls = kwargs.pop('FigureClass', Figure)
3503 fig = fig_cls(*args, **kwargs)
-> [3504](https://file+.vscode-resource.vscode-cdn.net/home/firestar/NAOC/HVC-catalog/Test/~/.miniforge/lib/python3.13/site-packages/matplotlib/backend_bases.py:3504) return cls.new_figure_manager_given_figure(num, fig)

File ~/.miniforge/lib/python3.13/site-packages/ipympl/backend_nbagg.py:430, in _Backend_ipympl.new_figure_manager_given_figure(num, figure)
428 if 'nbagg.transparent' in rcParams and rcParams['nbagg.transparent']:
429 figure.patch.set_alpha(0)
--> [430](https://file+.vscode-resource.vscode-cdn.net/home/firestar/NAOC/HVC-catalog/Test/~/.miniforge/lib/python3.13/site-packages/ipympl/backend_nbagg.py:430) manager = FigureManager(canvas, num)
432 if is_interactive():
433 _Backend_ipympl._to_show.append(figure)

File ~/.miniforge/lib/python3.13/site-packages/ipympl/backend_nbagg.py:402, in FigureManager.__init__(self, canvas, num)
400 FigureManagerWebAgg.__init__(self, canvas, num)
401 self.web_sockets = [self.canvas]
--> [402](https://file+.vscode-resource.vscode-cdn.net/home/firestar/NAOC/HVC-catalog/Test/~/.miniforge/lib/python3.13/site-packages/ipympl/backend_nbagg.py:402) self.toolbar = Toolbar(self.canvas)

File ~/.miniforge/lib/python3.13/site-packages/ipympl/backend_nbagg.py:126, in Toolbar.__init__(self, canvas, *args, **kwargs)
125 def __init__(self, canvas, *args, **kwargs):
--> [126](https://file+.vscode-resource.vscode-cdn.net/home/firestar/NAOC/HVC-catalog/Test/~/.miniforge/lib/python3.13/site-packages/ipympl/backend_nbagg.py:126) DOMWidget.__init__(self, *args, **kwargs)
127 NavigationToolbar2WebAgg.__init__(self, canvas, *args, **kwargs)
129 self.on_msg(self.canvas._handle_message)

File ~/.miniforge/lib/python3.13/site-packages/ipywidgets/widgets/widget.py:503, in Widget.__init__(self, **kwargs)
501 """Public constructor"""
502 self._model_id = kwargs.pop('model_id', None)
--> [503](https://file+.vscode-resource.vscode-cdn.net/home/firestar/NAOC/HVC-catalog/Test/~/.miniforge/lib/python3.13/site-packages/ipywidgets/widgets/widget.py:503) super().__init__(**kwargs)
505 Widget._call_widget_constructed(self)
506 self.open()

File ~/.miniforge/lib/python3.13/site-packages/traitlets/traitlets.py:1385, in HasTraits.__init__(self, *args, **kwargs)
1383 arg_s_list.append(f"{k}={v!r}")
1384 arg_s = ", ".join(arg_s_list)
-> [1385](https://file+.vscode-resource.vscode-cdn.net/home/firestar/NAOC/HVC-catalog/Test/~/.miniforge/lib/python3.13/site-packages/traitlets/traitlets.py:1385) warn(
1386 "Passing unrecognized arguments to super({classname}).__init__({arg_s}).\n"
1387 "{error}\n"
1388 "This is deprecated in traitlets 4.2."
1389 "This error will be raised in a future release of traitlets.".format(
1390 arg_s=arg_s,
1391 classname=self.__class__.__name__,
1392 error=e,
1393 ),
1394 DeprecationWarning,
1395 stacklevel=2,
1396 )

File ~/.miniforge/lib/python3.13/site-packages/traitlets/utils/warnings.py:14, in warn(msg, category, stacklevel, source)
9 def warn(msg: str, category: t.Any, *, stacklevel: int, source: t.Any = None) -> None:
10 """Like warnings.warn(), but category and stacklevel are required.
11
12 You pretty much never want the default stacklevel of 1, so this helps
13 encourage setting it explicitly."""
---> [14](https://file+.vscode-resource.vscode-cdn.net/home/firestar/NAOC/HVC-catalog/Test/~/.miniforge/lib/python3.13/site-packages/traitlets/utils/warnings.py:14) warnings.warn(msg, category=category, stacklevel=stacklevel, source=source)

DeprecationWarning: Passing unrecognized arguments to super(Toolbar).__init__().
NavigationToolbar2WebAgg.__init__() missing 1 required positional argument: 'canvas'
This is deprecated in traitlets 4.2.This error will be raised in a future release of traitlets.
```

## Versions

```
3.13.11 | packaged by conda-forge | (main, Dec 6 2025, 11:24:03) [GCC 14.3.0]
ipympl version: 0.9.8
Selected Jupyter core packages...
IPython : 9.8.0
ipykernel : 7.1.0
ipywidgets : 8.1.8
jupyter_client : 8.7.0
jupyter_core : 5.9.1
jupyter_server : 2.17.0
jupyterlab : not installed
nbclient : 0.10.4
nbconvert : 7.16.6
nbformat : 5.10.4
notebook : not installed
qtconsole : not installed
traitlets : 5.14.3

```

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Riproduci l'avviso con Python 3.13, ipympl 0.9.8 e una chiamata a plt.subplots che utilizzi il backend ipympl. Ispeziona ipympl/backend_nbagg.py nelle vicinanze di Toolbar.__init__ e l'interazione mostrata tra traitlets e il costruttore di matplotlib; il lavoro è terminato quando è possibile creare la figura senza l'errore o l'avviso di deprecazione riportati.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
jupyter, matplotlib, python
Ambito
backend
Tipo di issue
Bug
Difficoltà
3/5
Tempo stimato
1-2 giorni
Stato di attività
Tranquilla
Chiarezza
Da chiarire
Idoneità per principianti
45/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.