Skip to content

Commit

Permalink
fix: make sure bounds for images are set consistently when using `cen…
Browse files Browse the repository at this point in the history
…ter` with `nx`/`ny` (#122)

* fix: make sure bounds for images are set consistently when using `center` with `nx`/`ny`

* test: update to latest test suite

* fix: make sure to get the pytest import

* test: update test module for more export bugs

* fix: need to have center in the floor operation

* test: ensure path to test input is correct
  • Loading branch information
beckermr authored Dec 11, 2024
1 parent 1e84752 commit b769e97
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
10 changes: 8 additions & 2 deletions jax_galsim/gsobject.py
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,9 @@ def _setup_image(
)
image = Image(nx, ny, dtype=dtype)
if center is not None:
# this code has to match the code in _get_new_bounds
# for the same branch of the if statement block
# if center, nx, and ny are given.
image.shift(
PositionI(
jnp.floor(center.x + 0.5 - image.true_center.x),
Expand Down Expand Up @@ -486,10 +489,13 @@ def _get_new_bounds(self, image, nx, ny, bounds, center):
elif nx is not None and ny is not None:
b = BoundsI(1, nx, 1, ny)
if center is not None:
# this code has to match the code in _setup_image
# for the same branch of the if statement block
# if center, nx and ny are given.
b = b.shift(
PositionI(
jnp.floor(center.x + 0.5) - b.center.x,
jnp.floor(center.y + 0.5) - b.center.y,
jnp.floor(center.x + 0.5 - b.true_center.x),
jnp.floor(center.y + 0.5 - b.true_center.y),
)
)
return b
Expand Down
2 changes: 1 addition & 1 deletion tests/GalSim
Submodule GalSim updated 105 files

0 comments on commit b769e97

Please sign in to comment.