Skip to content

Commit 906eb4f

Browse files
committed
[mypy] fix
* use quantities.umath.__all__ * ignore UnitQuantity.__hash__ * fix aliases as list[str] in golden_ratio (but not used) * dtype of npt.NDArray must be generic
1 parent 31ba87d commit 906eb4f

4 files changed

Lines changed: 33 additions & 7 deletions

File tree

quantities/constants/mathematical.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@
1212
'golden_ratio',
1313
(1 + _math.sqrt(5)) / 2,
1414
u_symbol='ϕ',
15-
aliases='golden'
15+
aliases=['golden']
1616
)

quantities/typing/quantities.pyi

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ from typing import Union, Iterable
22

33
from quantities import Quantity
44
from quantities.dimensionality import Dimensionality
5+
import numpy as np
56
import numpy.typing as npt
67

78
DimensionalityDescriptor = Union[str, Quantity, Dimensionality]
8-
QuantityData = Union[Quantity, npt.NDArray[Union[float,int]], Iterable[Union[float,int]], float, int]
9+
QuantityData = Union[Quantity, npt.NDArray[Union[np.floating, np.integer]], Iterable[Union[float, int]], float, int]

quantities/umath.py

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,38 @@
11
import numpy as np
22

33
from .quantity import Quantity
4-
from .units import dimensionless, radian, degree
4+
from .units import dimensionless, radian, degree # type: ignore[no-redef]
55
from .decorators import with_doc
66

77

8-
#__all__ = [
9-
# 'exp', 'expm1', 'log', 'log10', 'log1p', 'log2'
10-
#]
8+
__all__ = [
9+
"arccos",
10+
"arccosh",
11+
"arcsin",
12+
"arcsinh",
13+
"arctan",
14+
"arctan2",
15+
"arctanh",
16+
"cos",
17+
"cosh",
18+
"cross",
19+
"cumprod",
20+
"cumsum",
21+
"diff",
22+
"ediff1d",
23+
"gradient",
24+
"hypot",
25+
"nansum",
26+
"np",
27+
"prod",
28+
"sin",
29+
"sinh",
30+
"sum",
31+
"tan",
32+
"tanh",
33+
"trapz",
34+
"unwrap",
35+
]
1136

1237

1338
@with_doc(np.prod)

quantities/unitquantity.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class UnitQuantity(Quantity):
2323
) -> None:
2424
...
2525

26-
def __hash__(self) -> int:
26+
def __hash__(self) -> int: # type: ignore[override]
2727
...
2828

2929
@property

0 commit comments

Comments
 (0)