Skip to content

Commit a570512

Browse files
committed
Include data kwarg in pyi stubs
Allows for stubtest to check the consistency of many prominent user facing methods Currently no type hint is provided for data, a follow up issue will be filed detailing what needs to happen to make that have a useful type hint.
1 parent d4e92ce commit a570512

File tree

2 files changed

+63
-49
lines changed

2 files changed

+63
-49
lines changed

ci/mypy-stubtest-allowlist.txt

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -17,44 +17,6 @@ matplotlib.*\.set$
1717
matplotlib.pyplot.*
1818
matplotlib.typing.*
1919

20-
# _preprocess_data arg decorator
21-
matplotlib.axes.*Axes.acorr
22-
matplotlib.axes.*Axes.angle_spectrum
23-
matplotlib.axes.*Axes.bar
24-
matplotlib.axes.*Axes.barbs
25-
matplotlib.axes.*Axes.boxplot
26-
matplotlib.axes.*Axes.broken_barh
27-
matplotlib.axes.*Axes.cohere
28-
matplotlib.axes.*Axes.contour
29-
matplotlib.axes.*Axes.contourf
30-
matplotlib.axes.*Axes.csd
31-
matplotlib.axes.*Axes.ecdf
32-
matplotlib.axes.*Axes.errorbar
33-
matplotlib.axes.*Axes.eventplot
34-
matplotlib.axes.*Axes.fill_between
35-
matplotlib.axes.*Axes.fill_betweenx
36-
matplotlib.axes.*Axes.hexbin
37-
matplotlib.axes.*Axes.hist
38-
matplotlib.axes.*Axes.hist2d
39-
matplotlib.axes.*Axes.hlines
40-
matplotlib.axes.*Axes.imshow
41-
matplotlib.axes.*Axes.magnitude_spectrum
42-
matplotlib.axes.*Axes.pcolor
43-
matplotlib.axes.*Axes.pcolorfast
44-
matplotlib.axes.*Axes.pcolormesh
45-
matplotlib.axes.*Axes.phase_spectrum
46-
matplotlib.axes.*Axes.pie
47-
matplotlib.axes.*Axes.plot_date
48-
matplotlib.axes.*Axes.psd
49-
matplotlib.axes.*Axes.quiver
50-
matplotlib.axes.*Axes.scatter
51-
matplotlib.axes.*Axes.specgram
52-
matplotlib.axes.*Axes.stairs
53-
matplotlib.axes.*Axes.stem
54-
matplotlib.axes.*Axes.violinplot
55-
matplotlib.axes.*Axes.vlines
56-
matplotlib.axes.*Axes.xcorr
57-
5820
# Other decorator modifying signature (maybe investigate)
5921
matplotlib.axis.Axis.draw
6022
matplotlib.offsetbox.*Offset[Bb]ox.get_offset

lib/matplotlib/axes/_axes.pyi

Lines changed: 63 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,8 @@ class Axes(_AxesBase):
166166
colors: Sequence[ColorType] | None = ...,
167167
linestyles: LineStyleType = ...,
168168
label: str = ...,
169+
*,
170+
data=...,
169171
**kwargs
170172
) -> LineCollection: ...
171173
def vlines(
@@ -176,6 +178,8 @@ class Axes(_AxesBase):
176178
colors: Sequence[ColorType] | None = ...,
177179
linestyles: LineStyleType = ...,
178180
label: str = ...,
181+
*,
182+
data=...,
179183
**kwargs
180184
) -> LineCollection: ...
181185
def eventplot(
@@ -188,14 +192,16 @@ class Axes(_AxesBase):
188192
colors: ColorType | Sequence[ColorType] | None = ...,
189193
alpha: float | Sequence[float] | None = ...,
190194
linestyles: LineStyleType | Sequence[LineStyleType] = ...,
195+
*,
196+
data=...,
191197
**kwargs
192198
) -> EventCollection: ...
193199
def plot(
194200
self,
195201
*args: float | ArrayLike | str,
196202
scalex: bool = ...,
197203
scaley: bool = ...,
198-
data: Any | None = ...,
204+
data = ...,
199205
**kwargs
200206
) -> list[Line2D]: ...
201207
def plot_date(
@@ -206,13 +212,15 @@ class Axes(_AxesBase):
206212
tz: str | datetime.tzinfo | None = ...,
207213
xdate: bool = ...,
208214
ydate: bool = ...,
215+
*,
216+
data=...,
209217
**kwargs
210218
) -> list[Line2D]: ...
211219
def loglog(self, *args, **kwargs) -> list[Line2D]: ...
212220
def semilogx(self, *args, **kwargs) -> list[Line2D]: ...
213221
def semilogy(self, *args, **kwargs) -> list[Line2D]: ...
214222
def acorr(
215-
self, x: ArrayLike, **kwargs
223+
self, x: ArrayLike, *, data=..., **kwargs
216224
) -> tuple[np.ndarray, np.ndarray, LineCollection | Line2D, Line2D | None]: ...
217225
def xcorr(
218226
self,
@@ -222,6 +230,8 @@ class Axes(_AxesBase):
222230
detrend: Callable[[ArrayLike], ArrayLike] = ...,
223231
usevlines: bool = ...,
224232
maxlags: int = ...,
233+
*,
234+
data = ...,
225235
**kwargs
226236
) -> tuple[np.ndarray, np.ndarray, LineCollection | Line2D, Line2D | None]: ...
227237
def step(
@@ -230,7 +240,7 @@ class Axes(_AxesBase):
230240
y: ArrayLike,
231241
*args,
232242
where: Literal["pre", "post", "mid"] = ...,
233-
data: Any | None = ...,
243+
data = ...,
234244
**kwargs
235245
) -> list[Line2D]: ...
236246
def bar(
@@ -241,6 +251,7 @@ class Axes(_AxesBase):
241251
bottom: float | ArrayLike | None = ...,
242252
*,
243253
align: Literal["center", "edge"] = ...,
254+
data = ...,
244255
**kwargs
245256
) -> BarContainer: ...
246257
def barh(
@@ -251,7 +262,7 @@ class Axes(_AxesBase):
251262
left: float | ArrayLike | None = ...,
252263
*,
253264
align: Literal["center", "edge"] = ...,
254-
data: Any | None = ...,
265+
data = ...,
255266
**kwargs
256267
) -> BarContainer: ...
257268
def bar_label(
@@ -268,6 +279,8 @@ class Axes(_AxesBase):
268279
self,
269280
xranges: Sequence[tuple[float, float]],
270281
yrange: tuple[float, float],
282+
*,
283+
data=...,
271284
**kwargs
272285
) -> BrokenBarHCollection: ...
273286
def stem(
@@ -278,7 +291,8 @@ class Axes(_AxesBase):
278291
basefmt: str | None = ...,
279292
bottom: float = ...,
280293
label: str | None = ...,
281-
orientation: Literal["vertical", "horizontal"] = ...
294+
orientation: Literal["vertical", "horizontal"] = ...,
295+
data=...,
282296
) -> StemContainer: ...
283297

284298
# TODO: data kwarg preprocessor?
@@ -302,7 +316,8 @@ class Axes(_AxesBase):
302316
rotatelabels: bool = ...,
303317
*,
304318
normalize: bool = ...,
305-
hatch: str | Sequence[str] | None = ...
319+
hatch: str | Sequence[str] | None = ...,
320+
data=...,
306321
): ...
307322
def errorbar(
308323
self,
@@ -321,6 +336,8 @@ class Axes(_AxesBase):
321336
xuplims: bool = ...,
322337
errorevery: int | tuple[int, int] = ...,
323338
capthick: float | None = ...,
339+
*,
340+
data=...,
324341
**kwargs
325342
) -> ErrorbarContainer: ...
326343
def boxplot(
@@ -352,6 +369,8 @@ class Axes(_AxesBase):
352369
autorange: bool = ...,
353370
zorder: float | None = ...,
354371
capwidths: float | ArrayLike | None = ...,
372+
*,
373+
data=...,
355374
) -> dict[str, Any]: ...
356375
def bxp(
357376
self,
@@ -392,6 +411,7 @@ class Axes(_AxesBase):
392411
*,
393412
edgecolors: Literal["face", "none"] | ColorType | Sequence[ColorType] | None = ...,
394413
plotnonfinite: bool = ...,
414+
data=...,
395415
**kwargs
396416
) -> PathCollection: ...
397417
def hexbin(
@@ -414,6 +434,8 @@ class Axes(_AxesBase):
414434
reduce_C_function: Callable[[np.ndarray], float] = ...,
415435
mincnt: int | None = ...,
416436
marginals: bool = ...,
437+
*,
438+
data=...,
417439
**kwargs
418440
) -> PolyCollection: ...
419441
def arrow(
@@ -422,9 +444,9 @@ class Axes(_AxesBase):
422444
def quiverkey(
423445
self, Q: Quiver, X: float, Y: float, U: float, label: str, **kwargs
424446
) -> QuiverKey: ...
425-
def quiver(self, *args, **kwargs) -> Quiver: ...
426-
def barbs(self, *args, **kwargs) -> Barbs: ...
427-
def fill(self, *args, data: Any | None = ..., **kwargs) -> list[Polygon]: ...
447+
def quiver(self, *args, data=..., **kwargs) -> Quiver: ...
448+
def barbs(self, *args, data=..., **kwargs) -> Barbs: ...
449+
def fill(self, *args, data=..., **kwargs) -> list[Polygon]: ...
428450
def fill_between(
429451
self,
430452
x: ArrayLike,
@@ -433,6 +455,8 @@ class Axes(_AxesBase):
433455
where: Sequence[bool] | None = ...,
434456
interpolate: bool = ...,
435457
step: Literal["pre", "post", "mid"] | None = ...,
458+
*,
459+
data=...,
436460
**kwargs
437461
) -> PolyCollection: ...
438462
def fill_betweenx(
@@ -443,6 +467,8 @@ class Axes(_AxesBase):
443467
where: Sequence[bool] | None = ...,
444468
step: Literal["pre", "post", "mid"] | None = ...,
445469
interpolate: bool = ...,
470+
*,
471+
data=...,
446472
**kwargs
447473
) -> PolyCollection: ...
448474
def imshow(
@@ -463,6 +489,7 @@ class Axes(_AxesBase):
463489
filterrad: float = ...,
464490
resample: bool | None = ...,
465491
url: str | None = ...,
492+
data=...,
466493
**kwargs
467494
) -> AxesImage: ...
468495
def pcolor(
@@ -474,6 +501,7 @@ class Axes(_AxesBase):
474501
cmap: str | Colormap | None = ...,
475502
vmin: float | None = ...,
476503
vmax: float | None = ...,
504+
data=...,
477505
**kwargs
478506
) -> Collection: ...
479507
def pcolormesh(
@@ -486,6 +514,7 @@ class Axes(_AxesBase):
486514
vmax: float | None = ...,
487515
shading: Literal["flat", "nearest", "gouraud", "auto"] | None = ...,
488516
antialiased: bool = ...,
517+
data=...,
489518
**kwargs
490519
) -> QuadMesh: ...
491520
def pcolorfast(
@@ -496,10 +525,11 @@ class Axes(_AxesBase):
496525
cmap: str | Colormap | None = ...,
497526
vmin: float | None = ...,
498527
vmax: float | None = ...,
528+
data=...,
499529
**kwargs
500530
) -> AxesImage | PcolorImage | QuadMesh: ...
501-
def contour(self, *args, **kwargs) -> QuadContourSet: ...
502-
def contourf(self, *args, **kwargs) -> QuadContourSet: ...
531+
def contour(self, *args, data=..., **kwargs) -> QuadContourSet: ...
532+
def contourf(self, *args, data=..., **kwargs) -> QuadContourSet: ...
503533
def clabel(
504534
self, CS: ContourSet, levels: ArrayLike | None = ..., **kwargs
505535
) -> list[Text]: ...
@@ -520,6 +550,8 @@ class Axes(_AxesBase):
520550
color: ColorType | Sequence[ColorType] | None = ...,
521551
label: str | Sequence[str] | None = ...,
522552
stacked: bool = ...,
553+
*,
554+
data=...,
523555
**kwargs
524556
) -> tuple[
525557
np.ndarray | list[np.ndarray],
@@ -534,6 +566,7 @@ class Axes(_AxesBase):
534566
orientation: Literal["vertical", "horizontal"] = ...,
535567
baseline: float | ArrayLike = ...,
536568
fill: bool = ...,
569+
data=...,
537570
**kwargs
538571
) -> StepPatch: ...
539572
def hist2d(
@@ -550,6 +583,8 @@ class Axes(_AxesBase):
550583
weights: ArrayLike | None = ...,
551584
cmin: float | None = ...,
552585
cmax: float | None = ...,
586+
*,
587+
data=...,
553588
**kwargs
554589
) -> tuple[np.ndarray, np.ndarray, np.ndarray, QuadMesh]: ...
555590
def ecdf(
@@ -560,6 +595,7 @@ class Axes(_AxesBase):
560595
complementary: bool=...,
561596
orientation: Literal["vertical", "horizonatal"]=...,
562597
compress: bool=...,
598+
data=...,
563599
**kwargs
564600
) -> Line2D: ...
565601
def psd(
@@ -577,6 +613,8 @@ class Axes(_AxesBase):
577613
sides: Literal["default", "onesided", "twosided"] | None = ...,
578614
scale_by_freq: bool | None = ...,
579615
return_line: bool | None = ...,
616+
*,
617+
data=...,
580618
**kwargs
581619
) -> tuple[np.ndarray, np.ndarray] | tuple[np.ndarray, np.ndarray, Line2D]: ...
582620
def csd(
@@ -595,6 +633,8 @@ class Axes(_AxesBase):
595633
sides: Literal["default", "onesided", "twosided"] | None = ...,
596634
scale_by_freq: bool | None = ...,
597635
return_line: bool | None = ...,
636+
*,
637+
data=...,
598638
**kwargs
599639
) -> tuple[np.ndarray, np.ndarray] | tuple[np.ndarray, np.ndarray, Line2D]: ...
600640
def magnitude_spectrum(
@@ -606,6 +646,8 @@ class Axes(_AxesBase):
606646
pad_to: int | None = ...,
607647
sides: Literal["default", "onesided", "twosided"] | None = ...,
608648
scale: Literal["default", "linear", "dB"] | None = ...,
649+
*,
650+
data=...,
609651
**kwargs
610652
) -> tuple[np.ndarray, np.ndarray, Line2D]: ...
611653
def angle_spectrum(
@@ -616,6 +658,8 @@ class Axes(_AxesBase):
616658
window: Callable[[ArrayLike], ArrayLike] | ArrayLike | None = ...,
617659
pad_to: int | None = ...,
618660
sides: Literal["default", "onesided", "twosided"] | None = ...,
661+
*,
662+
data=...,
619663
**kwargs
620664
) -> tuple[np.ndarray, np.ndarray, Line2D]: ...
621665
def phase_spectrum(
@@ -626,6 +670,8 @@ class Axes(_AxesBase):
626670
window: Callable[[ArrayLike], ArrayLike] | ArrayLike | None = ...,
627671
pad_to: int | None = ...,
628672
sides: Literal["default", "onesided", "twosided"] | None = ...,
673+
*,
674+
data=...,
629675
**kwargs
630676
) -> tuple[np.ndarray, np.ndarray, Line2D]: ...
631677
def cohere(
@@ -642,6 +688,8 @@ class Axes(_AxesBase):
642688
pad_to: int | None = ...,
643689
sides: Literal["default", "onesided", "twosided"] = ...,
644690
scale_by_freq: bool | None = ...,
691+
*,
692+
data=...,
645693
**kwargs
646694
) -> tuple[np.ndarray, np.ndarray]: ...
647695
def specgram(
@@ -664,6 +712,8 @@ class Axes(_AxesBase):
664712
scale: Literal["default", "linear", "dB"] | None = ...,
665713
vmin: float | None = ...,
666714
vmax: float | None = ...,
715+
*,
716+
data=...,
667717
**kwargs
668718
) -> tuple[np.ndarray, np.ndarray, np.ndarray, AxesImage]: ...
669719
def spy(
@@ -692,6 +742,8 @@ class Axes(_AxesBase):
692742
| float
693743
| Callable[[GaussianKDE], float]
694744
| None = ...,
745+
*,
746+
data=...,
695747
) -> dict[str, Collection]: ...
696748
def violin(
697749
self,

0 commit comments

Comments
 (0)