From 1067c3b780197eebf4a21378e4b6ec82ed651510 Mon Sep 17 00:00:00 2001 From: Jan Petykiewicz Date: Fri, 8 Jan 2021 23:02:55 -0800 Subject: [PATCH] Fix loop variables not getting saved in closures --- gridlock/draw.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gridlock/draw.py b/gridlock/draw.py index af80047..6865c5d 100644 --- a/gridlock/draw.py +++ b/gridlock/draw.py @@ -153,7 +153,7 @@ def draw_polygons(self, # 2) Generate weights in z-direction w_z = numpy.zeros(((bdi_max - bdi_min + 1)[surface_normal], )) - def get_zi(offset): + def get_zi(offset, i=i, w_z=w_z): edges = self.shifted_exyz(i)[surface_normal] point = center[surface_normal] + offset grid_coord = numpy.digitize(point, edges) - 1 @@ -365,7 +365,7 @@ def draw_extrude_rectangle(self, ind[direction] += 1 eps += mult[1] * grid[ind] - def f_eps(xs, ys, zs): + def f_eps(xs, ys, zs, i=i, eps=eps) -> numpy.ndarray: # transform from natural position to index xyzi = numpy.array([self.pos2ind(qrs, which_shifts=i) for qrs in zip(xs.flat, ys.flat, zs.flat)], dtype=int)