Skip to content

Commit

Permalink
recycle unused memory to prevent allocation #168
Browse files Browse the repository at this point in the history
  • Loading branch information
jacanchaplais committed Nov 23, 2023
1 parent 8ca9b1e commit 0ef34c4
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion graphicle/calculate.py
Original file line number Diff line number Diff line change
Expand Up @@ -666,7 +666,7 @@ def _assignment_cost(
) -> base.DoubleVector:
dist_matrix = _delta_R(rapidity_1, rapidity_2, xy_pol_1, xy_pol_2)
num_partons = dist_matrix.shape[0]
pt_2_cache = np.abs(xy_pol_2)
pt_2_cache = np.abs(xy_pol_2, out=rapidity_2)
var_pt_recip = 1.0 / np.var(pt_2_cache)
for parton_idx in nb.prange(num_partons):
row = dist_matrix[parton_idx, :]
Expand Down
1 change: 1 addition & 0 deletions graphicle/select.py
Original file line number Diff line number Diff line change
Expand Up @@ -1228,6 +1228,7 @@ def arg_closest(
focus._xy_pol,
candidate._xy_pol,
)
del candidate.rapidity # inplace operation above invalidates cache
_, idxs = opt.linear_sum_assignment(cost_matrix)
return idxs.tolist()

Expand Down

0 comments on commit 0ef34c4

Please sign in to comment.