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

Fix centering bug reported in #1322 #1323

Merged
merged 4 commits into from
Dec 9, 2024
Merged

Fix centering bug reported in #1322 #1323

merged 4 commits into from
Dec 9, 2024

Conversation

rmjarvis
Copy link
Member

@rmjarvis rmjarvis commented Dec 7, 2024

@rmjarvis rmjarvis requested a review from beckermr December 7, 2024 16:10
@rmjarvis rmjarvis added base classes Related to GSObject, Image, or other base GalSim classes bug report Bug report labels Dec 7, 2024
@rmjarvis rmjarvis added this to the v2.6 milestone Dec 7, 2024
b = b.shift(_PositionI(np.floor(center.x+0.5)-b.center.x,
np.floor(center.y+0.5)-b.center.y))
b = b.shift(_PositionI(np.floor(center.x+0.5-b.true_center.x),
np.floor(center.y+0.5-b.true_center.y)))
Copy link
Member Author

Choose a reason for hiding this comment

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

Worth mentioning that here is the other line, which this should be consistent with (and wasn't).

Copy link
Contributor

@beckermr beckermr left a comment

Choose a reason for hiding this comment

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

Thanks for the fix!

I have two related questions, none of them should block this PR but might be good fodder for future work.

  1. Is it worth trying to systematically add tests that exercise all of the drawing options in each combination? I was surprised to find this bug and it reminded me that even if the coverage is near 100%, we can still miss bugs because we have not hit all possible paths through the code.

  2. Is it worth trying to do some internal refactoring on some of the private methods to avoid the need to have certain lines of code be kept in sync? For example, I wonder if it is possible to refactor things such that the wcs, bounds, etc is all made up front and then the image is generated from those. This might help different bits of the code be more robust to changes maybe?

In any case, LGTM and thank you!

Copy link
Contributor

@beckermr beckermr left a comment

Choose a reason for hiding this comment

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

Ack one other thing. Let's add comments to the two relevant code lines that need to be the same stating that and referring to the other line so future folks understand when reading the code.

@rmjarvis
Copy link
Member Author

rmjarvis commented Dec 7, 2024

  1. We do try. We apparently missed these combinations that you discovered. There were a bunch of other tests that test various combinations of offset and center and such. But I think mostly with given bounds, rather than creating new ones. And the ones that tested that combination apparently wasn't comprehensive enough. If you have further ideas of a test that would be more comprehensive, I'd be happy to add it.
  2. Possibly. I thought about refactoring the _setup_image to use new_bounds rather than recapitulate the same calculation when necessary. But (a) I didn't want to gratuitously break any code that uses this private method. At least not in a bugfix release. And (b) I wasn't positive that there wasn't a good reason that I didn't already do it that way.

@beckermr
Copy link
Contributor

beckermr commented Dec 7, 2024

Sounds good. Thank you and LGTM!

@rmjarvis rmjarvis merged commit e1ed489 into releases/2.6 Dec 9, 2024
10 checks passed
@rmjarvis rmjarvis deleted the #1322 branch December 9, 2024 18:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
base classes Related to GSObject, Image, or other base GalSim classes bug report Bug report
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants