Open
Description
Bug summary
The overloads for subfigures
aren't quite correct
The issue is that
matplotlib/lib/matplotlib/figure.py
Line 1604 in 4af03f4
has squeeze=True
as the default, but the first overload incorrectly notes False
as the default
matplotlib/lib/matplotlib/figure.pyi
Lines 193 to 204 in 1295158
Code for reproduction
import matplotlib.pyplot as plt
from typing import reveal_type
fig = plt.figure(layout='constrained', figsize=(10, 4))
reveal_type(fig.subfigures(1, 2, wspace=0.07))
reveal_type(fig.subfigures(1, 1, wspace=0.07))
reveal_type(fig.subfigures(1, 2, wspace=0.07, squeeze=True))
reveal_type(fig.subfigures(1, 1, wspace=0.07, squeeze=True))
Actual outcome
(running the above with mypy)
t.py:6: note: Revealed type is "numpy.ndarray[builtins.tuple[Any, ...], numpy.dtype[Any]]"
t.py:7: note: Revealed type is "numpy.ndarray[builtins.tuple[Any, ...], numpy.dtype[Any]]"
t.py:9: note: Revealed type is "Union[numpy.ndarray[builtins.tuple[Any, ...], numpy.dtype[Any]], matplotlib.figure.SubFigure]"
t.py:10: note: Revealed type is "Union[numpy.ndarray[builtins.tuple[Any, ...], numpy.dtype[Any]], matplotlib.figure.SubFigure]"
Note that the reveal types differ, even though squeeze=True
is the default
Expected outcome
t.py:6: note: Revealed type is "Union[numpy.ndarray[builtins.tuple[Any, ...], numpy.dtype[Any]], matplotlib.figure.SubFigure]"
t.py:7: note: Revealed type is "Union[numpy.ndarray[builtins.tuple[Any, ...], numpy.dtype[Any]], matplotlib.figure.SubFigure]"
t.py:9: note: Revealed type is "Union[numpy.ndarray[builtins.tuple[Any, ...], numpy.dtype[Any]], matplotlib.figure.SubFigure]"
t.py:10: note: Revealed type is "Union[numpy.ndarray[builtins.tuple[Any, ...], numpy.dtype[Any]], matplotlib.figure.SubFigure]"
Additional information
No response
Operating system
No response
Matplotlib Version
3.10.3
Matplotlib Backend
No response
Python version
3.12
Jupyter version
No response
Installation
pip