diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 9880a6e04..89b91da0b 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -11,7 +11,7 @@ repos: - id: check-yaml - repo: https://github.com/PyCQA/isort - rev: 5.10.1 + rev: 5.13.2 hooks: - id: isort diff --git a/pyproject.toml b/pyproject.toml index 38539dfd8..044ff9ab1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -30,7 +30,7 @@ dependencies = [ "pybtex>=0.24", "spglib>=1.9", "upf-to-json>=0.9.5", - "ase-koopmans==0.1.4", + "ase-koopmans==0.1.5", "scikit-learn>=1.0", "deepdiff>=5.8.1", ] diff --git a/src/koopmans/calculators/_koopmans_cp.py b/src/koopmans/calculators/_koopmans_cp.py index 6f2fe28f2..882c49f4d 100644 --- a/src/koopmans/calculators/_koopmans_cp.py +++ b/src/koopmans/calculators/_koopmans_cp.py @@ -63,7 +63,7 @@ def good_fft(nr: int) -> int: return nr -def read_ham_file(filename: Path) -> np.ndarray[Any, np.dtype[np.cfloat]]: +def read_ham_file(filename: Path) -> np.ndarray[Any, np.dtype[np.complex128]]: # Read a single hamiltonian XML file if not filename.exists(): raise FileExistsError(f'{filename} does not exist') @@ -77,7 +77,7 @@ def read_ham_file(filename: Path) -> np.ndarray[Any, np.dtype[np.cfloat]]: assert ham_xml.text is not None, f'{filename} is empty' ham_array = np.array([complex(*[float(x) for x in line.split(',')]) - for line in ham_xml.text.strip().split('\n')], dtype=np.cfloat) * utils.units.Hartree + for line in ham_xml.text.strip().split('\n')], dtype=np.complex128) * utils.units.Hartree return ham_array.reshape((length, length)) diff --git a/src/koopmans/calculators/_ui/_calculator.py b/src/koopmans/calculators/_ui/_calculator.py index a0227d620..37eff68f8 100644 --- a/src/koopmans/calculators/_ui/_calculator.py +++ b/src/koopmans/calculators/_ui/_calculator.py @@ -50,13 +50,13 @@ def __init__(self, atoms: Atoms, *args, **kwargs): self.atoms.calc = self # Intermediate variables - self.centers: NDArray[np.float_] = np.array([]) + self.centers: NDArray[np.float64] = np.array([]) self.spreads: List[float] = [] self.phases: List[complex] = [] - self.hr: NDArray[np.complex_] = np.array([]) - self.hr_coarse: NDArray[np.complex_] = np.array([]) - self.hr_smooth: NDArray[np.complex_] = np.array([]) - self.hk: NDArray[np.complex_] = np.array([]) + self.hr: NDArray[np.complex128] = np.array([]) + self.hr_coarse: NDArray[np.complex128] = np.array([]) + self.hr_smooth: NDArray[np.complex128] = np.array([]) + self.hk: NDArray[np.complex128] = np.array([]) self.Rvec: NDArray[np.int_] = np.array([]) self.Rsmooth: NDArray[np.int_] = np.array([]) self.wRs: List[int] = [] @@ -308,7 +308,7 @@ def parse_phases(self) -> None: self.phases = [] return - def print_centers(self, centers: NDArray[np.float_] = np.array([])) -> None: + def print_centers(self, centers: NDArray[np.float64] = np.array([])) -> None: """ print_centers simply prints out the centers in the following Xcrysden-readable format: @@ -649,7 +649,7 @@ def calc_dos(self) -> None: return - def correct_phase(self) -> NDArray[np.complex_]: + def correct_phase(self) -> NDArray[np.complex128]: """ correct_phase calculate the correct phase factor to put in the Fourier transform to get the interpolated k-space hamiltonian. The correction consists diff --git a/src/koopmans/calculators/_ui/_utils.py b/src/koopmans/calculators/_ui/_utils.py index 66eaf1b2d..dfb0e9526 100644 --- a/src/koopmans/calculators/_ui/_utils.py +++ b/src/koopmans/calculators/_ui/_utils.py @@ -12,7 +12,7 @@ from numpy.typing import ArrayLike, NDArray -def crys_to_cart(vec: NDArray[np.float_], trmat: NDArray[np.float_], typ: int) -> NDArray[np.float_]: +def crys_to_cart(vec: NDArray[np.float64], trmat: NDArray[np.float64], typ: int) -> NDArray[np.float64]: """ Function to transform the numpy array vec (or a list/array of numpy arrays) from crystal to cartesian (in alat units), or viceversa, as it is done in QE: typ=+1 @@ -33,7 +33,8 @@ def crys_to_cart(vec: NDArray[np.float_], trmat: NDArray[np.float_], typ: int) - return vec_tr -def extract_hr(hr: NDArray[np.complex_], rvect: NDArray[np.int_], nr1: int, nr2: int, nr3: int) -> NDArray[np.complex_]: +def extract_hr(hr: NDArray[np.complex128], rvect: NDArray[np.int_], + nr1: int, nr2: int, nr3: int) -> NDArray[np.complex128]: """ Function to select the Wannier Hamiltonian only on the primitive cell R-vectors. The Hamiltonian coming from a Wannier90 calculation with k-points is indeed diff --git a/src/koopmans/calculators/_utils.py b/src/koopmans/calculators/_utils.py index ced8a8aac..b41b60aaf 100644 --- a/src/koopmans/calculators/_utils.py +++ b/src/koopmans/calculators/_utils.py @@ -311,7 +311,7 @@ class ReturnsBandStructure(ABC): """ @abstractmethod - def eigenvalues_from_results(self) -> npt.NDArray[np.float_]: + def eigenvalues_from_results(self) -> npt.NDArray[np.float64]: ... @abstractmethod diff --git a/src/koopmans/utils/_io.py b/src/koopmans/utils/_io.py index 1a29d9e0d..0675322b1 100644 --- a/src/koopmans/utils/_io.py +++ b/src/koopmans/utils/_io.py @@ -265,7 +265,7 @@ def read_wannier_hr_file(fname: Path) -> Tuple[np.ndarray, np.ndarray, List[int] return hr_np, rvect_np, weights, nrpts -def read_wannier_u_file(fname: Path) -> Tuple[npt.NDArray[np.complex_], npt.NDArray[np.float_], int]: +def read_wannier_u_file(fname: Path) -> Tuple[npt.NDArray[np.complex128], npt.NDArray[np.float64], int]: with open(fname, 'r') as fd: lines = fd.readlines() @@ -286,7 +286,7 @@ def read_wannier_u_file(fname: Path) -> Tuple[npt.NDArray[np.complex_], npt.NDAr return umat, kpts, nk -def write_wannier_u_file(fname: Path, umat: npt.NDArray[np.complex_], kpts: npt.NDArray[np.float_]): +def write_wannier_u_file(fname: Path, umat: npt.NDArray[np.complex128], kpts: npt.NDArray[np.float64]): flines = [f' Written on {datetime.now().isoformat(timespec="seconds")}'] flines.append(''.join([f'{x:12d}' for x in umat.shape]))