Skip to content

Commit

Permalink
fix: speed up
Browse files Browse the repository at this point in the history
using numpy meshgrid for calculating index list
for structured grid.
  • Loading branch information
Lachlan Grose committed Oct 26, 2021
1 parent 16c01ea commit e5b53d8
Showing 1 changed file with 1 addition and 10 deletions.
11 changes: 1 addition & 10 deletions LoopStructural/interpolators/structured_grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,16 +161,7 @@ def neighbour_global_indexes(self, mask = None, **kwargs):
if "indexes" in kwargs:
indexes = kwargs['indexes']
if "indexes" not in kwargs:
ii = []
jj = []
kk = []
for i in range(1, self.nsteps[0] - 1):
for j in range(1, self.nsteps[1] - 1):
for k in range(1, self.nsteps[2] - 1):
kk.append(k)
ii.append(i)
jj.append(j)
indexes = np.array([ii, jj, kk])
indexes = np.array(np.meshgrid(np.arange(1,nsteps[0]-1),np.arange(1,nsteps[1]-1),np.arange(1,nsteps[1]-1))).reshape((3,-1))
# indexes = np.array(indexes).T
if indexes.ndim != 2:
print(indexes.ndim)
Expand Down

0 comments on commit e5b53d8

Please sign in to comment.