@@ -538,7 +538,7 @@ def _read_tb(iterator, ignore_orbital_order=False):
538
538
539
539
lattice = np .zeros ((3 , 3 ))
540
540
for i in range (3 ):
541
- lattice [i , :] = np .fromstring (next (iterator ), sep = ' ' )
541
+ lattice [i , :] = np .fromstring (next (iterator ), sep = " " )
542
542
543
543
num_wann = int (next (iterator ))
544
544
@@ -554,28 +554,32 @@ def _read_tb(iterator, ignore_orbital_order=False):
554
554
# <0n|H|Rm>
555
555
hop_list = []
556
556
for ir in range (nrpts ):
557
- next (iterator ) # skip empty
557
+ next (iterator ) # skip empty
558
558
r_vec = [int (_ ) for _ in next (iterator ).strip ().split ()]
559
559
for j in range (num_wann ):
560
560
for i in range (num_wann ):
561
561
line = next (iterator ).strip ().split ()
562
562
iw , jw = [int (_ ) for _ in line [:2 ]]
563
563
if not ignore_orbital_order and (iw != i + 1 or jw != j + 1 ):
564
- raise ValueError (f"Inconsistent orbital numbers in line '{ line } '" )
564
+ raise ValueError (
565
+ f"Inconsistent orbital numbers in line '{ line } '"
566
+ )
565
567
ham = (float (line [2 ]) + 1j * float (line [3 ])) / deg_pts [ir ]
566
568
hop_list .append ([ham , i , j , r_vec ])
567
569
568
570
# <0n|r|Rm>
569
571
r_list = []
570
572
for ir in range (nrpts ):
571
- next (iterator ) # skip empty
573
+ next (iterator ) # skip empty
572
574
r_vec = [int (_ ) for _ in next (iterator ).strip ().split ()]
573
575
for j in range (num_wann ):
574
576
for i in range (num_wann ):
575
577
line = next (iterator ).strip ().split ()
576
578
iw , jw = [int (_ ) for _ in line [:2 ]]
577
579
if not ignore_orbital_order and (iw != i + 1 or jw != j + 1 ):
578
- raise ValueError (f"Inconsistent orbital numbers in line '{ line } '" )
580
+ raise ValueError (
581
+ f"Inconsistent orbital numbers in line '{ line } '"
582
+ )
579
583
r = np .array ([float (_ ) for _ in line [2 :]])
580
584
r = r [::2 ] + 1j * r [1 ::2 ]
581
585
r_list .append ([r , i , j , r_vec ])
@@ -769,7 +773,7 @@ def remap_hoppings(hop_entries):
769
773
return cls .from_hop_list (size = num_wann , hop_list = hop_entries , ** kwargs )
770
774
771
775
@classmethod # noqa: MC0001
772
- def from_wannier_tb_file ( # pylint: disable=too-many-locals
776
+ def from_wannier_tb_files ( # pylint: disable=too-many-locals
773
777
cls ,
774
778
* ,
775
779
tb_file : str ,
@@ -803,19 +807,19 @@ def from_wannier_tb_file( # pylint: disable=too-many-locals
803
807
804
808
with open (tb_file ) as f :
805
809
lattice , num_wann , nrpts , deg_pts , hop_list , r_list = cls ._read_tb (f )
806
-
810
+
807
811
kwargs ["uc" ] = lattice
808
812
809
- def get_centers (r_list : list ) -> list :
810
- centers = [None for _ in range (num_wann )]
813
+ def get_centers (r_list : ty . List [ ty . Any ] ) -> ty . List [ npt . NDArray [ np . float_ ]] :
814
+ centers = [np . zeros ( 3 ) for _ in range (num_wann )]
811
815
for r , i , j , r_vec in r_list :
812
816
if r_vec != [0 , 0 , 0 ]:
813
817
continue
814
818
if i != j :
815
819
continue
816
820
r = np .array (r )
817
821
if not np .allclose (np .abs (r .imag ), 0 ):
818
- raise ValueError (f' Center should be real: WF { i + 1 } , center = { r } ' )
822
+ raise ValueError (f" Center should be real: WF { i + 1 } , center = { r } " )
819
823
centers [i ] = r .real
820
824
return centers
821
825
@@ -829,21 +833,15 @@ def get_centers(r_list: list) -> list:
829
833
hop_entries = hop_list
830
834
831
835
with open (wsvec_file ) as f :
832
- wsvec_generator = cls ._async_parse (
833
- cls ._read_wsvec (f ), chunksize = num_wann
834
- )
836
+ wsvec_generator = cls ._async_parse (cls ._read_wsvec (f ), chunksize = num_wann )
835
837
836
838
def remap_hoppings (hop_entries ):
837
839
for t , orbital_1 , orbital_2 , R in hop_entries :
838
840
# Step _async_parse to where it accepts
839
841
# a new key.
840
842
# The _async_parse does not raise StopIteration
841
- next ( # pylint: disable=stop-iteration-return
842
- wsvec_generator
843
- )
844
- T_list = wsvec_generator .send (
845
- (orbital_1 , orbital_2 , tuple (R ))
846
- )
843
+ next (wsvec_generator ) # pylint: disable=stop-iteration-return
844
+ T_list = wsvec_generator .send ((orbital_1 , orbital_2 , tuple (R )))
847
845
N = len (T_list )
848
846
for T in T_list :
849
847
# not using numpy here increases performance
@@ -856,9 +854,7 @@ def remap_hoppings(hop_entries):
856
854
857
855
hop_entries = remap_hoppings (hop_entries )
858
856
859
- return cls .from_hop_list (
860
- size = num_wann , hop_list = hop_entries , ** kwargs
861
- )
857
+ return cls .from_hop_list (size = num_wann , hop_list = hop_entries , ** kwargs )
862
858
863
859
@staticmethod
864
860
def _async_parse (iterator , chunksize = 1 ):
0 commit comments