@@ -633,13 +633,15 @@ def from_wannier_files( # pylint: disable=too-many-locals
633633 wannier_pos_cartesian = np .array (wannier_pos_list_cartesian )
634634 atom_pos_cartesian = np .array ([a .pos for a in atom_list_cartesian ])
635635 if pos_kind == "wannier" :
636- pos_cartesian = wannier_pos_cartesian
636+ pos_cartesian : ty .Union [
637+ ty .List [np .ndarray ], np .ndarray
638+ ] = wannier_pos_cartesian
637639 elif pos_kind == "nearest_atom" :
638640 if distance_ratio_threshold < 1 :
639641 raise ValueError (
640642 "Invalid value for 'distance_ratio_threshold': must be >= 1."
641643 )
642- pos_cartesian = []
644+ pos_cartesian = ty . cast ( ty . List [ np . ndarray ], [])
643645 for p in wannier_pos_cartesian :
644646 p_reduced = la .solve (kwargs ["uc" ].T , np .array (p ).T ).T
645647 T_base = np .floor (p_reduced )
@@ -1130,7 +1132,7 @@ def hamilton(
11301132 H = pos_exponential .conjugate ().transpose ((0 , 2 , 1 )) * H * pos_exponential
11311133
11321134 if single_point :
1133- return H [0 ]
1135+ return ty . cast ( np . ndarray , H [0 ])
11341136 return H
11351137
11361138 def eigenval (
@@ -1149,7 +1151,7 @@ def eigenval(
11491151 hamiltonians = self .hamilton (k )
11501152 if hamiltonians .ndim == 3 :
11511153 return [la .eigvalsh (ham ) for ham in hamiltonians ]
1152- return la .eigvalsh (hamiltonians )
1154+ return ty . cast ( np . ndarray , la .eigvalsh (hamiltonians ) )
11531155
11541156 # -------------------MODIFYING THE MODEL ----------------------------#
11551157 def add_hop (
@@ -1272,8 +1274,8 @@ def remove_long_range_hop(self, *, cutoff_distance_cartesian: float) -> None:
12721274 "determine the cartesian distance between orbitals."
12731275 )
12741276 pos_cart = (self .uc .T @ self .pos .T ).T
1275- pos_offset_cart = pos_cart .reshape (1 , - 1 , self .dim ) - pos_cart .reshape (
1276- - 1 , 1 , self .dim
1277+ pos_offset_cart = pos_cart .reshape (( 1 , - 1 , self .dim ) ) - pos_cart .reshape (
1278+ ( - 1 , 1 , self .dim )
12771279 )
12781280
12791281 # Cast to list because the dictionary is modified in the loop.
@@ -1320,7 +1322,7 @@ def set_sparse(self, sparse: bool = True):
13201322 # change existing matrices
13211323 with contextlib .suppress (AttributeError ):
13221324 for k , v in self .hop .items ():
1323- self .hop [k ] = self ._matrix_type (v )
1325+ self .hop [k ] = self ._matrix_type (v ) # type: ignore
13241326
13251327 # If Python 3.4 support is dropped this could be made more straightforwardly
13261328 # However, for now the default pickle protocol (and thus multiprocessing)
@@ -1592,7 +1594,7 @@ def change_unit_cell( # pylint: disable=too-many-branches
15921594 )
15931595 # convert to reduced coordinates
15941596 if uc is None :
1595- new_uc = self .uc
1597+ new_uc : ty . Optional [ np . ndarray ] = self .uc
15961598 uc_reduced = np .eye (self .dim )
15971599 else :
15981600 new_uc = np .array (uc )
@@ -1635,7 +1637,7 @@ def change_unit_cell( # pylint: disable=too-many-branches
16351637 for R , hop_mat in self .hop .items ():
16361638 new_R = la .solve (uc_reduced .T , R )
16371639 assert np .allclose (np .round (new_R ), new_R )
1638- new_R = tuple (new_R .astype (int ))
1640+ new_R = tuple (np . round ( new_R ) .astype (int ))
16391641 new_hop [new_R ] = hop_mat
16401642
16411643 return Model (
0 commit comments