Skip to content

Commit

Permalink
Fix units for older versions of unyt
Browse files Browse the repository at this point in the history
  • Loading branch information
cphyc committed Nov 20, 2024
1 parent 80736ad commit 2c28d1d
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions yt/visualization/volume_rendering/off_axis_projection.py
Original file line number Diff line number Diff line change
Expand Up @@ -445,8 +445,16 @@ def temp_weightfield(field, data):
# i.e. we ignore the z-component
wmax = width[:2].max()
# Recenter positions w.r.t. center of the plot window
xyz = np.stack(
[data_source["index", k] - center[i] for i, k in enumerate("xyz")], axis=-1
units = data_source["index", "x"].units
xyz = data_source.apply_units(
np.stack(
[
data_source["index", k] - center[i].to(units)
for i, k in enumerate("xyz")
],
axis=-1,
),
units,
)

# If we have periodic boundaries, we need to wrap the positions
Expand Down

0 comments on commit 2c28d1d

Please sign in to comment.