Skip to content

Commit

Permalink
fixed typing reference to Tuple
Browse files Browse the repository at this point in the history
typing on intrinsics is first introduced in 3.9

Signed-off-by: Nick Papior <[email protected]>
  • Loading branch information
zerothi committed Nov 2, 2023
1 parent f3633fb commit 6695ea3
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 14 deletions.
4 changes: 3 additions & 1 deletion src/sisl/geom/nanotube.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
from typing import Tuple

import numpy as np

from sisl import Atom, Geometry, Lattice
Expand All @@ -14,7 +16,7 @@
@set_module("sisl.geom")
def nanotube(bond: float,
atoms=None,
chirality: tuple[int, int]=(1, 1)):
chirality: Tuple[int, int]=(1, 1)):
""" Nanotube with user-defined chirality.
This routine is implemented as in `ASE`_ with some cosmetic changes.
Expand Down
8 changes: 4 additions & 4 deletions src/sisl/geom/surfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from collections import namedtuple
from itertools import groupby
from numbers import Integral
from typing import Sequence, Union
from typing import Sequence, Tuple, Union

import numpy as np

Expand Down Expand Up @@ -277,7 +277,7 @@ def iter_func(key, layer):
@set_module("sisl.geom")
def fcc_slab(alat: float,
atoms,
miller: Union[int, str, tuple[int, int, int]],
miller: Union[int, str, Tuple[int, int, int]],
layers=None,
vacuum: Union[float, Sequence[float]]=20.,
*,
Expand Down Expand Up @@ -471,7 +471,7 @@ def fcc_slab(alat: float,
@set_module("sisl.geom")
def bcc_slab(alat: float,
atoms,
miller: Union[int, str, tuple[int, int, int]],
miller: Union[int, str, Tuple[int, int, int]],
layers=None,
vacuum: Union[float, Sequence[float]]=20.,
*,
Expand Down Expand Up @@ -625,7 +625,7 @@ def bcc_slab(alat: float,
@set_module("sisl.geom")
def rocksalt_slab(alat: float,
atoms,
miller: Union[int, str, tuple[int, int, int]],
miller: Union[int, str, Tuple[int, int, int]],
layers=None,
vacuum: Union[float, Sequence[float]]=20.,
*,
Expand Down
18 changes: 9 additions & 9 deletions src/sisl/geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from math import acos
from numbers import Integral, Real
from pathlib import Path
from typing import TYPE_CHECKING, Iterator, List, Optional, Union
from typing import TYPE_CHECKING, Iterator, List, Optional, Tuple, Union

import numpy as np
from numpy import (
Expand Down Expand Up @@ -933,7 +933,7 @@ def iR(self,
def iter_block_rand(self,
iR: int=20,
R: Optional[float]=None,
atoms: Optional[AtomsArgument]=None) -> Iterator[tuple[ndarray, ndarray]]:
atoms: Optional[AtomsArgument]=None) -> Iterator[Tuple[ndarray, ndarray]]:
"""Perform the *random* block-iteration by randomly selecting the next center of block """

# We implement yields as we can then do nested iterators
Expand Down Expand Up @@ -1010,7 +1010,7 @@ def iter_block_rand(self,
def iter_block_shape(self,
shape=None,
iR: int=20,
atoms: Optional[AtomsArgument]=None) -> Iterator[tuple[ndarray, ndarray]]:
atoms: Optional[AtomsArgument]=None) -> Iterator[Tuple[ndarray, ndarray]]:
"""Perform the *grid* block-iteration by looping a grid """

# We implement yields as we can then do nested iterators
Expand Down Expand Up @@ -1137,7 +1137,7 @@ def iter_block(self,
iR: int=20,
R: Optional[float]=None,
atoms: Optional[AtomsArgument]=None,
method: str='rand') -> Iterator[tuple[ndarray, ndarray]]:
method: str='rand') -> Iterator[Tuple[ndarray, ndarray]]:
"""Iterator for performance critical loops
NOTE: This requires that `R` has been set correctly as the maximum interaction range.
Expand Down Expand Up @@ -1209,7 +1209,7 @@ def overlap(self,
other: GeometryLikeType,
eps: float=0.1,
offset=(0., 0., 0.),
offset_other=(0., 0., 0.)) -> tuple[ndarray, ndarray]:
offset_other=(0., 0., 0.)) -> Tuple[ndarray, ndarray]:
""" Calculate the overlapping indices between two geometries
Find equivalent atoms (in the primary unit-cell only) in two geometries.
Expand Down Expand Up @@ -1264,7 +1264,7 @@ def overlap(self,
other_extend(idx)
return _a.arrayi(idx_self), _a.arrayi(idx_other)

def sort(self, **kwargs) -> Union[Geometry, tuple[Geometry, List]]:
def sort(self, **kwargs) -> Union[Geometry, Tuple[Geometry, List]]:
r""" Sort atoms in a nested fashion according to various criteria
There are many ways to sort a `Geometry`.
Expand Down Expand Up @@ -4031,7 +4031,7 @@ def isc_tile(isc, n):

def a2transpose(self,
atoms1: AtomsArgument,
atoms2: Optional[AtomsArgument]=None) -> tuple[ndarray, ndarray]:
atoms2: Optional[AtomsArgument]=None) -> Tuple[ndarray, ndarray]:
"""Transposes connections from `atoms1` to `atoms2` such that supercell connections are transposed
When handling supercell indices it is useful to get the *transposed* connection. I.e. if you have
Expand Down Expand Up @@ -4095,7 +4095,7 @@ def a2transpose(self,

def o2transpose(self,
orb1: OrbitalsArgument,
orb2: Optional[OrbitalsArgument]=None) -> tuple[ndarray, ndarray]:
orb2: Optional[OrbitalsArgument]=None) -> Tuple[ndarray, ndarray]:
""" Transposes connections from `orb1` to `orb2` such that supercell connections are transposed
When handling supercell indices it is useful to get the *transposed* connection. I.e. if you have
Expand Down Expand Up @@ -4639,7 +4639,7 @@ def within_inf(self,
lattice: Lattice,
periodic=None,
tol: float=1e-5,
origin=None) -> tuple[ndarray, ndarray, ndarray]:
origin=None) -> Tuple[ndarray, ndarray, ndarray]:
""" Find all atoms within a provided supercell
Note this function is rather different from `close` and `within`.
Expand Down

0 comments on commit 6695ea3

Please sign in to comment.