Skip to content

Commit bf7d853

Browse files
authored
Merge pull request #186 from Yoofin/test
Update hfun/raster.py
2 parents b05289e + e13267a commit bf7d853

File tree

1 file changed

+17
-20
lines changed

1 file changed

+17
-20
lines changed

ocsmesh/hfun/raster.py

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -344,29 +344,26 @@ def msh_t(
344344
dim2 = win.height
345345

346346
tria3 = np.empty(
347-
((dim1 - 1), (dim2 - 1)),
348-
dtype=jigsaw_msh_t.TRIA3_t)
347+
(dim1 - 1, dim2 - 1),
348+
dtype=jigsaw_msh_t.TRIA3_t,
349+
)
349350
index = tria3["index"]
350-
helper_ary = np.ones(
351-
((dim1 - 1), (dim2 - 1)),
352-
dtype=jigsaw_msh_t.INDEX_t).cumsum(1) - 1
353-
index[:, :, 0] = np.arange(
354-
0, dim1 - 1,
355-
dtype=jigsaw_msh_t.INDEX_t).reshape(dim1 - 1, 1)
356-
index[:, :, 0] += (helper_ary + 0) * dim1
357-
358-
index[:, :, 1] = np.arange(
359-
1, dim1 - 0,
360-
dtype=jigsaw_msh_t.INDEX_t).reshape(dim1 - 1, 1)
361-
index[:, :, 1] += (helper_ary + 0) * dim1
362-
363-
index[:, :, 2] = np.arange(
364-
1, dim1 - 0,
365-
dtype=jigsaw_msh_t.INDEX_t).reshape(dim1 - 1, 1)
366-
index[:, :, 2] += (helper_ary + 1) * dim1
351+
352+
i = np.arange(
353+
dim1 - 1,
354+
dtype=jigsaw_msh_t.INDEX_t,
355+
)[:, None]
356+
j = np.arange(
357+
dim2 - 1,
358+
dtype=jigsaw_msh_t.INDEX_t,
359+
)[None, :]
360+
361+
index[:, :, 0] = i + j * dim1
362+
index[:, :, 1] = (i+1) + j * dim1
363+
index[:, :, 2] = (i+1) + (j+1) * dim1
367364

368365
hfun.tria3 = tria3.ravel()
369-
del tria3, helper_ary
366+
370367
gc.collect()
371368
_logger.info('Done building hfun.tria3...')
372369

0 commit comments

Comments
 (0)