File tree Expand file tree Collapse file tree 1 file changed +5
-3
lines changed Expand file tree Collapse file tree 1 file changed +5
-3
lines changed Original file line number Diff line number Diff line change 34
34
)
35
35
from typing_extensions import Self
36
36
37
- Scalar = complex
37
+ import numpy as np
38
+
39
+ Scalar = Union [complex , np .number ]
38
40
TVector = TypeVar ('TVector' )
39
41
40
42
TDefault = TypeVar ('TDefault' )
@@ -124,7 +126,7 @@ def _check_vector_valid(self, vector: TVector) -> None:
124
126
125
127
def clean (self , * , atol : float = 1e-9 ) -> Self :
126
128
"""Remove terms with coefficients of absolute value atol or less."""
127
- negligible = [v for v , c in self ._terms .items () if abs (c ) <= atol ]
129
+ negligible = [v for v , c in self ._terms .items () if abs (complex ( c ) ) <= atol ]
128
130
for v in negligible :
129
131
del self ._terms [v ]
130
132
return self
@@ -245,7 +247,7 @@ def __mul__(self, a: Scalar) -> Self:
245
247
result *= a
246
248
return result
247
249
248
- def __rmul__ (self , a : Scalar ) -> Self :
250
+ def __rmul__ (self , a : Scalar ) -> Self : # type: ignore
249
251
return self .__mul__ (a )
250
252
251
253
def __truediv__ (self , a : Scalar ) -> Self :
You can’t perform that action at this time.
0 commit comments