Skip to content

Commit

Permalink
MNT: set a consistent nomenclature for the distance squared parameter.
Browse files Browse the repository at this point in the history
In parts of the 'map_grid' method it was referred to as 'dist' whereas
in another as 'dist2' (parameter calculation lines differ in style but
identical in value), resulting in an unnecessary scalar allocation,
and a confusing nomenclature.
  • Loading branch information
isilber committed Jan 18, 2024
1 parent 9c47087 commit d8899ce
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions pyart/map/_gate_to_grid_map.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ cdef class GateToGridMapper:
int weighting_function, float zdist_factor):
""" Map a single gate to the grid. """

cdef float xg, yg, zg, dist, weight, roi2, dist2, min_dist2
cdef float xg, yg, zg, weight, roi2, dist2, min_dist2
cdef int x_min, x_max, y_min, y_max, z_min, z_max
cdef int xi, yi, zi, x_argmin, y_argmin, z_argmin

Expand Down Expand Up @@ -348,12 +348,12 @@ cdef class GateToGridMapper:
xg = self.x_step * xi
yg = self.y_step * yi
zg = self.z_step * zi
dist = ((xg - x)**2 + (yg - y)**2 + zdist_factor * (zg - z)**2)
if dist >= roi2:
dist2 = ((xg - x)**2 + (yg - y)**2 + zdist_factor * (zg - z)**2)
if dist2 >= roi2:
continue
for i in range(self.nfields):
if dist < self.min_dist2[zi, yi, xi, i]:
self.min_dist2[zi, yi, xi, i] = dist
if dist2 < self.min_dist2[zi, yi, xi, i]:
self.min_dist2[zi, yi, xi, i] = dist2
x_argmin = xi
y_argmin = yi
z_argmin = zi
Expand Down

0 comments on commit d8899ce

Please sign in to comment.