Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG: fix NaNs in off-center FRB slices from ds.r #5112

Merged
merged 1 commit into from
Feb 4, 2025

Conversation

yut23
Copy link
Member

@yut23 yut23 commented Feb 4, 2025

PR Summary

FRBs of slices made with ds.r were selecting the wrong area when the center of the slice didn't match the center of the domain. The existing tests didn't catch this, as they only check regions that have the same center as the domain. I've added a test case that covers this.

Example code and resulting plots:

import yt
import matplotlib.pyplot as plt

ds = yt.load_sample("IsolatedGalaxy")
region = ds.r[0:0.5:100j, 0.5:1.0:100j, 0.5]

# display NaNs as red
cmap = plt.colormaps["viridis"]
cmap.set_bad(color="red")

plt.imshow(region["index", "x"], origin="lower", vmin=0, vmax=1, cmap=cmap)
plt.colorbar()

before
after

PR Checklist

  • Adds a test for any bugs fixed. Adds tests for new features.

@yut23 yut23 added the bug label Feb 4, 2025
Copy link
Contributor

@chrishavlin chrishavlin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice catch, the fix looks good to me.

@chrishavlin chrishavlin added this to the 4.4.1 milestone Feb 4, 2025
@chrishavlin chrishavlin merged commit 1b7aee2 into yt-project:main Feb 4, 2025
13 checks passed
meeseeksmachine pushed a commit to meeseeksmachine/yt that referenced this pull request Feb 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants