@@ -62,9 +62,7 @@ class AugmentedPKDTree(object):
6262
6363 """
6464
65- def __init__ (
66- self , box : Optional [npt .ArrayLike ] = None , leafsize : int = 10
67- ) -> None :
65+ def __init__ (self , box : Optional [npt .ArrayLike ] = None , leafsize : int = 10 ) -> None :
6866 """
6967
7068 Parameters
@@ -98,9 +96,7 @@ def pbc(self):
9896 """
9997 return self .box is not None
10098
101- def set_coords (
102- self , coords : npt .ArrayLike , cutoff : Optional [float ] = None
103- ) -> None :
99+ def set_coords (self , coords : npt .ArrayLike , cutoff : Optional [float ] = None ) -> None :
104100 """Constructs KDTree from the coordinates
105101
106102 Wrapping of coordinates to the primary unit cell is enforced
@@ -147,18 +143,15 @@ def set_coords(
147143 # Bring the coordinates in the central cell
148144 self .coords = apply_PBC (coords , self .box )
149145 # generate duplicate images
150- self .aug , self .mapping = augment_coordinates (
151- self .coords , self .box , cutoff
152- )
146+ self .aug , self .mapping = augment_coordinates (self .coords , self .box , cutoff )
153147 # Images + coords
154148 self .all_coords = np .concatenate ([self .coords , self .aug ])
155149 self .ckdt = cKDTree (self .all_coords , leafsize = self .leafsize )
156150 else :
157151 # if cutoff distance is provided for non PBC calculations
158152 if cutoff is not None :
159153 raise RuntimeError (
160- "Donot provide cutoff distance for"
161- " non PBC aware calculations"
154+ "Donot provide cutoff distance for" " non PBC aware calculations"
162155 )
163156 self .coords = coords
164157 self .ckdt = cKDTree (self .coords , self .leafsize )
@@ -189,9 +182,7 @@ def search(self, centers: npt.ArrayLike, radius: float) -> npt.NDArray:
189182 # Sanity check
190183 if self .pbc :
191184 if self .cutoff is None :
192- raise ValueError (
193- "Cutoff needs to be provided when working with PBC."
194- )
185+ raise ValueError ("Cutoff needs to be provided when working with PBC." )
195186 if self .cutoff < radius :
196187 raise RuntimeError ("Set cutoff greater or equal to the radius." )
197188 # Bring all query points to the central cell
@@ -241,21 +232,15 @@ def search_pairs(self, radius: float) -> npt.NDArray:
241232
242233 if self .pbc :
243234 if self .cutoff is None :
244- raise ValueError (
245- "Cutoff needs to be provided when working with PBC."
246- )
235+ raise ValueError ("Cutoff needs to be provided when working with PBC." )
247236 if self .cutoff < radius :
248237 raise RuntimeError ("Set cutoff greater or equal to the radius." )
249238
250239 pairs = np .array (list (self .ckdt .query_pairs (radius )), dtype = np .intp )
251240 if self .pbc :
252241 if len (pairs ) > 1 :
253- pairs [:, 0 ] = undo_augment (
254- pairs [:, 0 ], self .mapping , len (self .coords )
255- )
256- pairs [:, 1 ] = undo_augment (
257- pairs [:, 1 ], self .mapping , len (self .coords )
258- )
242+ pairs [:, 0 ] = undo_augment (pairs [:, 0 ], self .mapping , len (self .coords ))
243+ pairs [:, 1 ] = undo_augment (pairs [:, 1 ], self .mapping , len (self .coords ))
259244 if pairs .size > 0 :
260245 # First sort the pairs then pick the unique pairs
261246 pairs = np .sort (pairs , axis = 1 )
@@ -303,9 +288,7 @@ class initialization
303288 # Sanity check
304289 if self .pbc :
305290 if self .cutoff is None :
306- raise ValueError (
307- "Cutoff needs to be provided when working with PBC."
308- )
291+ raise ValueError ("Cutoff needs to be provided when working with PBC." )
309292 if self .cutoff < radius :
310293 raise RuntimeError ("Set cutoff greater or equal to the radius." )
311294 # Bring all query points to the central cell
@@ -317,9 +300,7 @@ class initialization
317300 dtype = np .intp ,
318301 )
319302 if pairs .size > 0 :
320- pairs [:, 1 ] = undo_augment (
321- pairs [:, 1 ], self .mapping , len (self .coords )
322- )
303+ pairs [:, 1 ] = undo_augment (pairs [:, 1 ], self .mapping , len (self .coords ))
323304 else :
324305 other_tree = cKDTree (centers , leafsize = self .leafsize )
325306 pairs = other_tree .query_ball_tree (self .ckdt , radius )
@@ -334,9 +315,7 @@ class initialization
334315
335316class PeriodicKDTree (object ):
336317
337- def __init__ (
338- self , box : Optional [npt .ArrayLike ] = None , leafsize : int = 10
339- ) -> None :
318+ def __init__ (self , box : Optional [npt .ArrayLike ] = None , leafsize : int = 10 ) -> None :
340319 self .leafsize = leafsize
341320 self .dim = 3
342321 self .box = box
@@ -374,9 +353,7 @@ def pbc(self):
374353 """
375354 return self .box is not None
376355
377- def set_coords (
378- self , coords : npt .ArrayLike , cutoff : Optional [float ] = None
379- ) -> None :
356+ def set_coords (self , coords : npt .ArrayLike , cutoff : Optional [float ] = None ) -> None :
380357 """Constructs KDTree from the coordinates
381358
382359 Parameters
@@ -439,9 +416,7 @@ def search(self, centers: npt.ArrayLike, radius: float) -> npt.NDArray:
439416
440417 if self .pbc :
441418 if self .cutoff is None :
442- raise ValueError (
443- "Cutoff needs to be provided when working with PBC."
444- )
419+ raise ValueError ("Cutoff needs to be provided when working with PBC." )
445420 if self .cutoff < radius :
446421 raise RuntimeError ("Set cutoff greater or equal to the radius." )
447422 wrapped_centers = apply_PBC (centers , self .box )
@@ -494,9 +469,7 @@ def search_pairs(self, radius: float) -> npt.NDArray:
494469
495470 if self .pbc :
496471 if self .cutoff is None :
497- raise ValueError (
498- "Cutoff needs to be provided when working with PBC."
499- )
472+ raise ValueError ("Cutoff needs to be provided when working with PBC." )
500473 if self .cutoff < radius :
501474 raise RuntimeError ("Set cutoff greater or equal to the radius." )
502475
@@ -541,9 +514,7 @@ def search_tree(self, centers: npt.ArrayLike, radius: float) -> np.ndarray:
541514
542515 if self .pbc :
543516 if self .cutoff is None :
544- raise ValueError (
545- "Cutoff needs to be provided when working with PBC."
546- )
517+ raise ValueError ("Cutoff needs to be provided when working with PBC." )
547518 if self .cutoff < radius :
548519 raise RuntimeError ("Set cutoff greater or equal to the radius." )
549520 wrapped_centers = apply_PBC (centers , self .box )
0 commit comments