@@ -35,9 +35,9 @@ def get_reasonable_repetitions(n_atoms: int) -> tuple[int, int, int]:
3535 return 1 , 1 , 1
3636
3737
38- def eigenvectors_from_displacements (disp : np . ndarray , masses : np . ndarray ) -> np .ndarray :
38+ def eigenvectors_from_displacements (disp : ArrayLike , masses : ArrayLike ) -> np .ndarray :
3939 """Calculate the eigenvectors from the atomic displacements."""
40- return np .einsum ("nax,a->nax" , disp , masses ** 0.5 ) # codespell :ignore nax
40+ return np .einsum ("nax,a->nax" , disp , masses ** 0.5 ) # type :ignore[arg-type]
4141
4242
4343def estimate_band_connection (prev_eigvecs , eigvecs , prev_band_order ) -> list [int ]:
@@ -67,12 +67,12 @@ class PhononBandStructure(MSONable):
6767
6868 def __init__ (
6969 self ,
70- qpoints : Sequence [ Kpoint ] ,
70+ qpoints : ArrayLike ,
7171 frequencies : ArrayLike ,
7272 lattice : Lattice ,
73- nac_frequencies : Sequence [ Sequence ] | None = None ,
73+ nac_frequencies : ArrayLike | None = None ,
7474 eigendisplacements : ArrayLike = None ,
75- nac_eigendisplacements : Sequence [ Sequence ] | None = None ,
75+ nac_eigendisplacements : ArrayLike | None = None ,
7676 labels_dict : dict | None = None ,
7777 coords_are_cartesian : bool = False ,
7878 structure : Structure | None = None ,
@@ -126,14 +126,14 @@ def __init__(
126126 if np .linalg .norm (q_pt - np .array (labels_dict [key ])) < 0.0001 :
127127 label = key
128128 self .labels_dict [label ] = Kpoint (
129- q_pt ,
129+ q_pt , # type:ignore[arg-type]
130130 lattice ,
131131 label = label ,
132132 coords_are_cartesian = coords_are_cartesian ,
133133 )
134134 self .qpoints += [
135135 Kpoint (
136- q_pt ,
136+ q_pt , # type:ignore[arg-type]
137137 lattice ,
138138 label = label ,
139139 coords_are_cartesian = coords_are_cartesian ,
@@ -148,10 +148,10 @@ def __init__(
148148 self .nac_eigendisplacements : list [tuple [list [float ], np .ndarray ]] = []
149149 if nac_frequencies is not None :
150150 for freq in nac_frequencies :
151- self .nac_frequencies .append (([idx / np .linalg .norm (freq [0 ]) for idx in freq [0 ]], freq [1 ]))
151+ self .nac_frequencies .append (([idx / np .linalg .norm (freq [0 ]) for idx in freq [0 ]], freq [1 ])) # type:ignore[arg-type]
152152 if nac_eigendisplacements is not None :
153153 for freq in nac_eigendisplacements :
154- self .nac_eigendisplacements .append (([idx / np .linalg .norm (freq [0 ]) for idx in freq [0 ]], freq [1 ]))
154+ self .nac_eigendisplacements .append (([idx / np .linalg .norm (freq [0 ]) for idx in freq [0 ]], freq [1 ])) # type:ignore[arg-type]
155155
156156 def get_gamma_point (self ) -> Kpoint | None :
157157 """Get the Gamma q-point as a Kpoint object (or None if not found)."""
@@ -219,7 +219,7 @@ def has_nac(self) -> bool:
219219 @property
220220 def has_eigendisplacements (self ) -> bool :
221221 """True if eigendisplacements are present."""
222- return len (self .eigendisplacements ) > 0
222+ return len (self .eigendisplacements ) > 0 # type:ignore[arg-type]
223223
224224 def get_nac_frequencies_along_dir (self , direction : Sequence ) -> np .ndarray | None :
225225 """Get the nac_frequencies for the given direction (not necessarily a versor).
@@ -353,7 +353,7 @@ class PhononBandStructureSymmLine(PhononBandStructure):
353353
354354 def __init__ (
355355 self ,
356- qpoints : Sequence [ Kpoint ] ,
356+ qpoints : ArrayLike ,
357357 frequencies : ArrayLike ,
358358 lattice : Lattice ,
359359 has_nac : bool = False ,
@@ -388,7 +388,7 @@ def __init__(
388388 provide projections to the band structure.
389389 """
390390 super ().__init__ (
391- qpoints = qpoints ,
391+ qpoints = qpoints , # type:ignore[arg-type]
392392 frequencies = frequencies ,
393393 lattice = lattice ,
394394 nac_frequencies = None ,
@@ -398,7 +398,7 @@ def __init__(
398398 coords_are_cartesian = coords_are_cartesian ,
399399 structure = structure ,
400400 )
401- self ._reuse_init (eigendisplacements , frequencies , has_nac , qpoints )
401+ self ._reuse_init (eigendisplacements , frequencies , has_nac , qpoints ) # type:ignore[arg-type]
402402
403403 def __repr__ (self ) -> str :
404404 bands , labels = self .bands .shape , list (self .labels_dict )
@@ -425,7 +425,7 @@ def _reuse_init(
425425 self .distance += [previous_distance ]
426426 else :
427427 self .distance += [
428- np .linalg .norm (self .qpoints [idx ].cart_coords - previous_qpoint .cart_coords ) + previous_distance
428+ np .linalg .norm (self .qpoints [idx ].cart_coords - previous_qpoint .cart_coords ) + previous_distance # type:ignore[list-item]
429429 ]
430430 previous_qpoint = self .qpoints [idx ]
431431 previous_distance = self .distance [idx ]
@@ -452,22 +452,22 @@ def _reuse_init(
452452 for idx in range (self .nb_qpoints ):
453453 # get directions with nac irrespectively of the label_dict. NB: with labels
454454 # the gamma point is expected to appear twice consecutively.
455- if np .allclose (qpoints [idx ], (0 , 0 , 0 )):
456- if idx > 0 and not np .allclose (qpoints [idx - 1 ], (0 , 0 , 0 )):
455+ if np .allclose (qpoints [idx ], (0 , 0 , 0 )): # type:ignore[arg-type]
456+ if idx > 0 and not np .allclose (qpoints [idx - 1 ], (0 , 0 , 0 )): # type:ignore[arg-type]
457457 q_dir = self .qpoints [idx - 1 ]
458458 direction = q_dir .frac_coords / np .linalg .norm (q_dir .frac_coords )
459459 naf .append ((direction , frequencies [:, idx ]))
460460 if self .has_eigendisplacements :
461461 nac_eigendisplacements .append ((direction , eigendisplacements [:, idx ]))
462- if idx < len (qpoints ) - 1 and not np .allclose (qpoints [idx + 1 ], (0 , 0 , 0 )):
462+ if idx < len (qpoints ) - 1 and not np .allclose (qpoints [idx + 1 ], (0 , 0 , 0 )): # type:ignore[arg-type]
463463 q_dir = self .qpoints [idx + 1 ]
464464 direction = q_dir .frac_coords / np .linalg .norm (q_dir .frac_coords )
465465 naf .append ((direction , frequencies [:, idx ]))
466466 if self .has_eigendisplacements :
467467 nac_eigendisplacements .append ((direction , eigendisplacements [:, idx ]))
468468
469- self .nac_frequencies = np .array (naf , dtype = object )
470- self .nac_eigendisplacements = np .array (nac_eigendisplacements , dtype = object )
469+ self .nac_frequencies = np .array (naf , dtype = object ) # type:ignore[assignment]
470+ self .nac_eigendisplacements = np .array (nac_eigendisplacements , dtype = object ) # type:ignore[assignment]
471471
472472 def get_equivalent_qpoints (self , index : int ) -> list [int ]:
473473 """Get the list of qpoint indices equivalent (meaning they are the
@@ -586,7 +586,7 @@ def as_phononwebsite(self) -> dict:
586586 line_breaks .append ((nq_start , nq ))
587587 nq_start = nq
588588 else :
589- dist += np .linalg .norm (q1 - q2 )
589+ dist += np .linalg .norm (q1 - q2 ) # type:ignore[assignment]
590590 distances .append (dist )
591591 line_breaks .append ((nq_start , len (qpoints )))
592592 dct ["distances" ] = distances
@@ -624,8 +624,8 @@ def band_reorder(self) -> None:
624624
625625 # Get order
626626 for nq in range (1 , n_qpoints ):
627- old_eig_vecs = eigenvectors_from_displacements (eigen_displacements [:, nq - 1 ], atomic_masses )
628- new_eig_vecs = eigenvectors_from_displacements (eigen_displacements [:, nq ], atomic_masses )
627+ old_eig_vecs = eigenvectors_from_displacements (eigen_displacements [:, nq - 1 ], atomic_masses ) # type:ignore[arg-type]
628+ new_eig_vecs = eigenvectors_from_displacements (eigen_displacements [:, nq ], atomic_masses ) # type:ignore[arg-type]
629629 order [nq ] = estimate_band_connection (
630630 old_eig_vecs .reshape ([n_phonons , n_phonons ]).T ,
631631 new_eig_vecs .reshape ([n_phonons , n_phonons ]).T ,
0 commit comments