|
30 | 30 | import operator |
31 | 31 | from abc import ABC, abstractmethod |
32 | 32 | from dataclasses import dataclass |
33 | | -from typing import TYPE_CHECKING, Any, Literal, cast, overload |
| 33 | +from typing import TYPE_CHECKING, Any, ClassVar, Literal, cast, overload |
34 | 34 |
|
35 | 35 | import numpy as np |
36 | 36 | from typing_extensions import deprecated |
@@ -78,7 +78,7 @@ def __init__(self, array_context: ArrayContext): |
78 | 78 | def _get_fake_numpy_linalg_namespace(self): |
79 | 79 | return BaseFakeNumpyLinalgNamespace(self._array_context) |
80 | 80 |
|
81 | | - _numpy_math_functions = frozenset({ |
| 81 | + _numpy_math_functions: ClassVar[frozenset[str]] = frozenset({ |
82 | 82 | # https://numpy.org/doc/stable/reference/routines.math.html |
83 | 83 |
|
84 | 84 | # FIXME: Heads up: not all of these are supported yet. |
@@ -560,7 +560,9 @@ def logical_not(self, x: ArrayOrContainerOrScalar, / |
560 | 560 |
|
561 | 561 | # {{{ BaseFakeNumpyLinalgNamespace |
562 | 562 |
|
563 | | -def _reduce_norm(actx: ArrayContext, arys: Iterable[ArrayOrScalar], ord: float | None): |
| 563 | +def _reduce_norm(actx: ArrayContext, |
| 564 | + arys: Iterable[ArrayOrScalar], |
| 565 | + ord: float | None) -> ArrayOrScalar: |
564 | 566 | from functools import reduce |
565 | 567 | from numbers import Number |
566 | 568 |
|
@@ -617,7 +619,7 @@ def norm(self, |
617 | 619 | raise NotImplementedError("only vector norms are implemented") |
618 | 620 |
|
619 | 621 | if ary.size == 0: |
620 | | - return ary.dtype.type(0) |
| 622 | + return cast("ScalarLike", ary.dtype.type(0)) |
621 | 623 |
|
622 | 624 | from numbers import Number |
623 | 625 | if ord == 2: |
|
0 commit comments