Skip to content

Commit 552c69d

Browse files
committed
improve typing in diffraction
1 parent c49922a commit 552c69d

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

freud/diffraction.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -762,9 +762,11 @@ def compute(
762762
self._diffraction = np.zeros((self.output_size, self.output_size))
763763
self._frame_counter = 0
764764

765-
system = freud.locality.NeighborQuery.from_system(system)
765+
neighbor_query: freud.locality.NeighborQuery = (
766+
freud.locality.NeighborQuery.from_system(system)
767+
)
766768

767-
if not system.box.cubic:
769+
if not neighbor_query.box.cubic:
768770
msg = "freud.diffraction.DiffractionPattern only supports cubic boxes"
769771
raise ValueError(msg)
770772

@@ -773,10 +775,10 @@ def compute(
773775
view_orientation = freud.util._convert_array(view_orientation, (4,), np.double)
774776

775777
# Compute the box projection matrix
776-
inv_shear = self._calc_proj(view_orientation, system.box)
778+
inv_shear = self._calc_proj(view_orientation, neighbor_query.box)
777779

778780
# Rotate points by the view quaternion and shear by the box projection
779-
xy = rowan.rotate(view_orientation, system.points)[:, 0:2]
781+
xy = rowan.rotate(view_orientation, neighbor_query.points)[:, 0:2]
780782
xy = xy @ inv_shear.T
781783

782784
# Normalize weights s.t. S(0) = N
@@ -806,9 +808,9 @@ def compute(
806808

807809
# Transform the image (scale, shear, zoom) and normalize S(k) by the
808810
# number of points
809-
self._N_points = len(system.points)
811+
self._N_points = len(neighbor_query.points)
810812
diffraction_frame = (
811-
self._transform(diffraction_frame, system.box, inv_shear, zoom)
813+
self._transform(diffraction_frame, neighbor_query.box, inv_shear, zoom)
812814
/ self._N_points
813815
)
814816

@@ -829,7 +831,7 @@ def compute(
829831

830832
# Cache the view orientation and box matrix scale factor for
831833
# lazy evaluation of k-values and k-vectors
832-
self._box_matrix_scale_factor = np.max(system.box.to_matrix())
834+
self._box_matrix_scale_factor = float(np.max(neighbor_query.box.to_matrix()))
833835
self._view_orientation = view_orientation
834836
self._k_scale_factor = (
835837
2 * np.pi * self.output_size / (self._box_matrix_scale_factor * zoom)
@@ -914,8 +916,8 @@ def to_image(
914916
if vmax is None:
915917
vmax = 0.7 * self.N_points
916918
norm = matplotlib.colors.LogNorm(vmin=vmin, vmax=vmax)
917-
cmap = matplotlib.colormaps[cmap]
918-
image = cmap(norm(np.clip(self.diffraction, vmin, vmax)))
919+
colormap = matplotlib.colormaps[cmap]
920+
image = colormap(norm(np.clip(self.diffraction, vmin, vmax)))
919921
return (image * 255).astype(np.uint8)
920922

921923
def plot(

0 commit comments

Comments
 (0)