Coverage for rhodent/typing.py: 94%
17 statements
« prev ^ index » next coverage.py v7.9.1, created at 2025-08-01 16:57 +0000
« prev ^ index » next coverage.py v7.9.1, created at 2025-08-01 16:57 +0000
1from __future__ import annotations
2from typing import Union, TypeVar
4import numpy as np
5from numpy.typing import NDArray
7from gpaw import mpi
8from gpaw.calculator import GPAW
10GPAWCalculator = GPAW
11Communicator = mpi._Communicator
12ArrayIndex = Union[NDArray[np.int_], list[int], int, slice]
15DTypeT = TypeVar('DTypeT', bound=np.generic, covariant=True)
18class ArrayIsOnRootRank(NDArray[DTypeT]):
19 def __new__(cls):
20 """ Instances will act as empty numpy arrays """
21 return NDArray.__new__(cls, (0, ))
24DistributedArray = Union[NDArray[DTypeT], ArrayIsOnRootRank]
25Array1D = np.ndarray[tuple[int], np.dtype[DTypeT]]
26Array2D = np.ndarray[tuple[int, int], np.dtype[DTypeT]]
27Array3D = np.ndarray[tuple[int, int, int], np.dtype[DTypeT]]