Skip to content
This repository was archived by the owner on Feb 17, 2021. It is now read-only.

Commit 022ffe5

Browse files
authored
Revert covariant generics and use TypeVar instead (#23)
* Revert covariant generics and use TypeVar instead * Fix small inconsistency in pyplot.pyi
1 parent ee8bbb2 commit 022ffe5

File tree

7 files changed

+250
-155
lines changed

7 files changed

+250
-155
lines changed

matplotlib-stubs/pyplot.pyi

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
from pathlib import Path as _Path
2-
from typing import Union, Sequence, Tuple, List, Optional, overload
1+
from pathlib import Path
2+
from typing import Union, Sequence, Tuple, List, Optional, overload, TypeVar
33
from typing_extensions import Literal
44

55
import numpy as _np
@@ -9,7 +9,8 @@ from .legend import Legend
99
from .image import AxesImage
1010
from .text import Text
1111

12-
_Data = Union[float, _np.ndarray[float], Sequence[float]]
12+
_Float = TypeVar("_Float", bound=_np.floating)
13+
_Data = Union[float, _np.ndarray[_Float], Sequence[float]]
1314

1415
_LegendLocation = Literal[
1516
"best",
@@ -28,8 +29,8 @@ class Axes:
2829
def set_xlabel(self, xlabel: str) -> None: ...
2930
def set_ylabel(self, ylabel: str) -> None: ...
3031
def set_title(self, label: str, loc: Literal["left", "center", "right"] = ...) -> None: ...
31-
def set_xticks(self, ticks: Union[_np.ndarray[_np.number], Sequence[float]]) -> None: ...
32-
def set_yticks(self, ticks: _Data) -> None: ...
32+
def set_xticks(self, ticks: Union[_np.ndarray[_Float], Sequence[float]]) -> None: ...
33+
def set_yticks(self, ticks: Union[_np.ndarray[_Float], Sequence[float]]) -> None: ...
3334
def set_xticklabels(self, labels: List[str]) -> Text: ...
3435
def set_yticklabels(self, labels: List[str]) -> Text: ...
3536
def grid(
@@ -91,7 +92,7 @@ class Axes:
9192
self, X: _Data, cmap: str = ..., vmin: float = ..., vmax: float = ...,
9293
) -> AxesImage: ...
9394
def hist(
94-
self, x: _Data, bins: Union[int, Sequence[float], _np.ndarray[_np.number]]
95+
self, x: _Data, bins: Union[int, Sequence[float], _np.ndarray[_Float]]
9596
) -> Tuple[List[_np.ndarray], _np.ndarray, List]: ...
9697
def plot(
9798
self,
@@ -114,7 +115,7 @@ class Axes:
114115
class Figure:
115116
def savefig(
116117
self,
117-
fname: _Path,
118+
fname: Path,
118119
dpi: int = ...,
119120
bbox_extra_artists: Sequence[Artist] = ...,
120121
bbox_inches: Optional[Literal["tight"]] = ...,

numpy-stubs/__init__.pyi

Lines changed: 74 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,77 @@
11
"""Public API of numpy"""
22
from . import testing, random
33

4-
# manual import wasn't working for some reason but * import does work, so...
5-
from ._core import *
4+
from ._core import (
5+
ndarray as ndarray,
6+
newaxis as newaxis,
7+
dtype as dtype,
8+
bool_ as bool_,
9+
number as number,
10+
floating as floating,
11+
float32 as float32,
12+
float64 as float64,
13+
integer as integer,
14+
int16 as int16,
15+
int32 as int32,
16+
int64 as int64,
17+
array as array,
18+
arange as arange,
19+
asarray as asarray,
20+
ascontiguousarray as ascontiguousarray,
21+
copy as copy,
22+
empty as empty,
23+
empty_like as empty_like,
24+
eye as eye,
25+
full as full,
26+
full_like as full_like,
27+
fromiter as fromiter,
28+
fromstring as fromstring,
29+
identity as identity,
30+
linspace as linspace,
31+
load as load,
32+
loadtxt as loadtxt,
33+
ones as ones,
34+
ones_like as ones_like,
35+
zeros as zeros,
36+
zeros_like as zeros_like,
37+
astype as astype,
38+
abs as abs,
39+
ceil as ceil,
40+
clip as clip,
41+
concatenate as concatenate,
42+
diag as diag,
43+
divide as divide,
44+
exp as exp,
45+
expand_dims as expand_dims,
46+
hstack as hstack,
47+
log as log,
48+
logical_and as logical_and,
49+
matmul as matmul,
50+
max as max,
51+
mean as mean,
52+
min as min,
53+
nonzero as nonzero,
54+
power as power,
55+
ravel as ravel,
56+
reshape as reshape,
57+
sign as sign,
58+
split as split,
59+
square as square,
60+
sqrt as sqrt,
61+
stack as stack,
62+
std as std,
63+
sum as sum,
64+
take as take,
65+
tile as tile,
66+
trace as trace,
67+
tril as tril,
68+
triu as triu,
69+
unique as unique,
70+
where as where,
71+
savetxt as savetxt,
72+
savez as savez,
73+
savez_compressed as savez_compressed,
74+
matrix as matrix,
75+
inf as inf,
76+
nan as nan,
77+
)

0 commit comments

Comments
 (0)