Skip to content

Commit 0b29430

Browse files
committed
Add a few more things Array is expected to do
1 parent 61dbd8e commit 0b29430

File tree

1 file changed

+29
-3
lines changed

1 file changed

+29
-3
lines changed

arraycontext/context.py

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,19 +171,30 @@
171171
THE SOFTWARE.
172172
"""
173173

174+
174175
from abc import ABC, abstractmethod
175176
from collections.abc import Callable, Mapping
176-
from typing import TYPE_CHECKING, Any, Protocol, TypeAlias, TypeVar, Union, overload
177+
from typing import (
178+
TYPE_CHECKING,
179+
Any,
180+
Literal,
181+
Protocol,
182+
TypeAlias,
183+
TypeVar,
184+
overload,
185+
)
177186
from warnings import warn
178187

179-
import numpy as np
180188
from typing_extensions import Self
181189

182190
from pymbolic.typing import Integer, Scalar as _Scalar
183191
from pytools import memoize_method
184192

185193

186194
if TYPE_CHECKING:
195+
import numpy as np
196+
from numpy.typing import DTypeLike
197+
187198
import loopy
188199
from pytools.tag import ToTagSetConvertible
189200

@@ -243,6 +254,21 @@ def __rpow__(self, other: Self | ScalarLike) -> Array: ...
243254
def __truediv__(self, other: Self | ScalarLike) -> Array: ...
244255
def __rtruediv__(self, other: Self | ScalarLike) -> Array: ...
245256

257+
def copy(self) -> Self: ...
258+
259+
@property
260+
def real(self) -> Array: ...
261+
@property
262+
def imag(self) -> Array: ...
263+
def conj(self) -> Array: ...
264+
265+
def astype(self, dtype: DTypeLike) -> Array: ...
266+
267+
def reshape(self,
268+
*shape: int,
269+
order: Literal["C"] | Literal["F"]
270+
) -> Array: ...
271+
246272

247273
# deprecated, use ScalarLike instead
248274
Scalar = _Scalar
@@ -287,7 +313,7 @@ def __rtruediv__(self, other: Self | ScalarLike) -> Array: ...
287313
ContainerOrScalarT = TypeVar("ContainerOrScalarT", bound="ArrayContainer | ScalarLike")
288314

289315

290-
NumpyOrContainerOrScalar = Union[np.ndarray, "ArrayContainer", ScalarLike]
316+
NumpyOrContainerOrScalar: TypeAlias = "np.ndarray | ArrayContainer | ScalarLike"
291317

292318
# }}}
293319

0 commit comments

Comments
 (0)