-
Notifications
You must be signed in to change notification settings - Fork 14
Fix JAX jit boundary in LensCalc + document decorator/JAX patterns #291
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -247,7 +247,12 @@ def tangential_eigen_value_from(self, grid, xp=np) -> aa.Array2D: | |
| convergence = self.convergence_2d_via_hessian_from(grid=grid, xp=xp) | ||
| shear_yx = self.shear_yx_2d_via_hessian_from(grid=grid, xp=xp) | ||
|
|
||
| return aa.Array2D(values=1 - convergence - shear_yx.magnitudes, mask=grid.mask) | ||
| if xp is np: | ||
| return aa.Array2D( | ||
| values=1 - convergence - shear_yx.magnitudes, mask=grid.mask | ||
| ) | ||
| magnitudes = xp.sqrt(shear_yx[:, 0] ** 2 + shear_yx[:, 1] ** 2) | ||
| return 1 - convergence - magnitudes | ||
|
Comment on lines
+250
to
+255
|
||
|
|
||
| def radial_eigen_value_from(self, grid, xp=np) -> aa.Array2D: | ||
| """ | ||
|
|
@@ -267,7 +272,12 @@ def radial_eigen_value_from(self, grid, xp=np) -> aa.Array2D: | |
| convergence = self.convergence_2d_via_hessian_from(grid=grid, xp=xp) | ||
| shear = self.shear_yx_2d_via_hessian_from(grid=grid, xp=xp) | ||
|
|
||
| return aa.Array2D(values=1 - convergence + shear.magnitudes, mask=grid.mask) | ||
| if xp is np: | ||
| return aa.Array2D( | ||
| values=1 - convergence + shear.magnitudes, mask=grid.mask | ||
| ) | ||
| magnitudes = xp.sqrt(shear[:, 0] ** 2 + shear[:, 1] ** 2) | ||
| return 1 - convergence + magnitudes | ||
|
Comment on lines
+275
to
+280
|
||
|
|
||
| def magnification_2d_from(self, grid, xp=np) -> aa.Array2D: | ||
| """ | ||
|
|
@@ -288,7 +298,9 @@ def magnification_2d_from(self, grid, xp=np) -> aa.Array2D: | |
|
|
||
| det_A = (1 - hessian_xx) * (1 - hessian_yy) - hessian_xy * hessian_yx | ||
|
|
||
| return aa.Array2D(values=1 / det_A, mask=grid.mask) | ||
| if xp is np: | ||
| return aa.Array2D(values=1 / det_A, mask=grid.mask) | ||
| return 1 / det_A | ||
|
Comment on lines
+301
to
+303
|
||
|
|
||
| def deflections_yx_scalar(self, y, x, pixel_scales): | ||
| """ | ||
|
|
@@ -465,7 +477,9 @@ def convergence_2d_via_hessian_from(self, grid, xp=np) -> aa.ArrayIrregular: | |
|
|
||
| convergence = 0.5 * (hessian_yy + hessian_xx) | ||
|
|
||
| return aa.ArrayIrregular(values=convergence) | ||
| if xp is np: | ||
| return aa.ArrayIrregular(values=convergence) | ||
| return convergence | ||
|
Comment on lines
+480
to
+482
|
||
|
|
||
| def shear_yx_2d_via_hessian_from(self, grid, xp=np) -> ShearYX2DIrregular: | ||
| """ | ||
|
|
@@ -506,7 +520,9 @@ def shear_yx_2d_via_hessian_from(self, grid, xp=np) -> ShearYX2DIrregular: | |
|
|
||
| shear_yx_2d = xp.stack([gamma_2, gamma_1], axis=-1) | ||
|
|
||
| return ShearYX2DIrregular(values=shear_yx_2d, grid=grid) | ||
| if xp is np: | ||
| return ShearYX2DIrregular(values=shear_yx_2d, grid=grid) | ||
| return shear_yx_2d | ||
|
Comment on lines
+523
to
+525
|
||
|
|
||
| def magnification_2d_via_hessian_from(self, grid, xp=np) -> aa.ArrayIrregular: | ||
| """ | ||
|
|
@@ -534,7 +550,9 @@ def magnification_2d_via_hessian_from(self, grid, xp=np) -> aa.ArrayIrregular: | |
|
|
||
| det_A = (1 - hessian_xx) * (1 - hessian_yy) - hessian_xy * hessian_yx | ||
|
|
||
| return aa.ArrayIrregular(values=1.0 / det_A) | ||
| if xp is np: | ||
| return aa.ArrayIrregular(values=1.0 / det_A) | ||
| return 1.0 / det_A | ||
|
Comment on lines
+553
to
+555
|
||
|
|
||
| def contour_list_from(self, grid, contour_array): | ||
| grid_contour = aa.Grid2DContour( | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The guidance says to avoid chaining with pipes, but the example immediately above uses a pipe (
find ... | xargs ...). Either adjust the recommendation (e.g. avoid complex pipelines) or update the example so the instructions are internally consistent.