Skip to content

Commit

Permalink
Remove redundant array slice operations
Browse files Browse the repository at this point in the history
  • Loading branch information
rafmudaf committed Mar 29, 2023
1 parent 362d97c commit dfc00c2
Showing 1 changed file with 4 additions and 16 deletions.
20 changes: 4 additions & 16 deletions floris/simulation/flow_field.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,10 +183,7 @@ def calculate_speed_ups(self, het_map, x, y, z=None):
# Calculate the 3-dimensional speed ups; reshape is needed as the generator
# adds an extra dimension
speed_ups = np.reshape(
[
het_map[0][i](x[i:i+1,:,:,:,:], y[i:i+1,:,:,:,:], z[i:i+1,:,:,:,:])
for i in range(len(het_map[0]))
],
[het_map[0][i](x[i:i+1], y[i:i+1], z[i:i+1]) for i in range( len(het_map[0]))],
np.shape(x)
)

Expand All @@ -195,10 +192,7 @@ def calculate_speed_ups(self, het_map, x, y, z=None):
if np.isnan(speed_ups).any():
idx_nan = np.where(np.isnan(speed_ups))
speed_ups_out_of_region = np.reshape(
[
het_map[1][i](x[i:i+1,:,:,:,:], y[i:i+1,:,:,:,:], z[i:i+1,:,:,:,:])
for i in range(len(het_map[1]))
],
[het_map[1][i](x[i:i+1], y[i:i+1], z[i:i+1]) for i in range(len(het_map[1]))],
np.shape(x)
)

Expand All @@ -208,10 +202,7 @@ def calculate_speed_ups(self, het_map, x, y, z=None):
# Calculate the 2-dimensional speed ups; reshape is needed as the generator
# adds an extra dimension
speed_ups = np.reshape(
[
het_map[0][i](x[i:i+1,:,:,:,:], y[i:i+1,:,:,:,:])
for i in range(len(het_map[0]))
],
[het_map[0][i](x[i:i+1], y[i:i+1]) for i in range(len(het_map[0]))],
np.shape(x)
)

Expand All @@ -220,10 +211,7 @@ def calculate_speed_ups(self, het_map, x, y, z=None):
if np.isnan(speed_ups).any():
idx_nan = np.where(np.isnan(speed_ups))
speed_ups_out_of_region = np.reshape(
[
het_map[1][i](x[i:i+1,:,:,:,:], y[i:i+1,:,:,:,:])
for i in range(len(het_map[1]))
],
[het_map[1][i](x[i:i+1], y[i:i+1]) for i in range(len(het_map[1]))],
np.shape(x)
)

Expand Down

0 comments on commit dfc00c2

Please sign in to comment.