Skip to content

Commit

Permalink
return image early
Browse files Browse the repository at this point in the history
  • Loading branch information
biboyd committed Apr 17, 2024
1 parent 10f3ef4 commit a104859
Showing 1 changed file with 23 additions and 23 deletions.
46 changes: 23 additions & 23 deletions yt/utilities/amr_kdtree/amr_kdtools.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,31 +10,31 @@ def receive_and_reduce(comm, incoming_rank, image, add_to_front, *, use_opacity=
(image.shape[0], image.shape[1], image.shape[2])
)

if use_opacity:
if add_to_front:
front = arr2
back = image
else:
front = image
back = arr2

if image.shape[2] == 3:
# Assume Projection Camera, Add
np.add(image, front, image)
return image

ta = 1.0 - front[:, :, 3]
np.maximum(ta, 0.0, ta)
# This now does the following calculation, but in a memory
# conservative fashion
# image[:,:,i ] = front[:,:,i] + ta*back[:,:,i]
image = back.copy()
for i in range(4):
np.multiply(image[:, :, i], ta, image[:, :, i])
np.add(image, front, image)
if not use_opacity:
np.add(image, arr2, image)
return image

if add_to_front:
front = arr2
back = image
else:
np.add(image, arr2, image)
front = image
back = arr2

if image.shape[2] == 3:
# Assume Projection Camera, Add
np.add(image, front, image)
return image

ta = 1.0 - front[:, :, 3]
np.maximum(ta, 0.0, ta)
# This now does the following calculation, but in a memory
# conservative fashion
# image[:,:,i ] = front[:,:,i] + ta*back[:,:,i]
image = back.copy()
for i in range(4):
np.multiply(image[:, :, i], ta, image[:, :, i])
np.add(image, front, image)

return image

Expand Down

0 comments on commit a104859

Please sign in to comment.