-
Notifications
You must be signed in to change notification settings - Fork 14
feature/ell_comps_division_0_bug_fix #278
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 |
|---|---|---|
|
|
@@ -28,6 +28,7 @@ def ell_comps_from(axis_ratio: float, angle: float, xp=np) -> Tuple[float, float | |
| return (ellip_y, ellip_x) | ||
|
|
||
|
|
||
|
|
||
| def axis_ratio_and_angle_from( | ||
| ell_comps: Tuple[float, float], xp=np | ||
| ) -> Tuple[float, float]: | ||
|
|
@@ -60,7 +61,7 @@ def axis_ratio_and_angle_from( | |
| ell_comps | ||
| The elliptical components of the light or mass profile which are converted to an angle. | ||
| """ | ||
| angle = xp.arctan2(ell_comps[0], ell_comps[1]) / 2 | ||
| angle = 0.5 * xp.arctan2(ell_comps[0], xp.where((ell_comps[0] == 0) & (ell_comps[1] == 0), 1.0, ell_comps[1])) | ||
| angle *= 180.0 / xp.pi | ||
|
|
||
| angle = xp.where(angle < -45, angle + 180, angle) | ||
|
|
@@ -197,7 +198,7 @@ def shear_magnitude_and_angle_from( | |
| gamma_2 | ||
| The gamma 2 component of the shear. | ||
| """ | ||
| angle = xp.arctan2(gamma_2, gamma_1) / 2 * 180.0 / xp.pi | ||
| angle = 0.5 * xp.arctan2(gamma_2, xp.where((gamma_1 == 0) & (gamma_2 == 0), 1.0, gamma_1)) * 180.0 / xp.pi | ||
| magnitude = xp.sqrt(gamma_1**2 + gamma_2**2) | ||
|
Comment on lines
+201
to
202
|
||
|
|
||
| angle = xp.where(angle < 0, angle + 180.0, angle) | ||
|
|
@@ -297,9 +298,15 @@ def multipole_k_m_and_phi_m_from( | |
| ------- | ||
| The normalization and angle parameters of the multipole. | ||
| """ | ||
| phi_m = ( | ||
| xp.arctan2(multipole_comps[0], multipole_comps[1]) * 180.0 / xp.pi / float(m) | ||
| ) | ||
| phi_m = xp.arctan2( | ||
| multipole_comps[0], | ||
| xp.where( | ||
| (multipole_comps[0] == 0) & (multipole_comps[1] == 0), | ||
| 1.0, | ||
| multipole_comps[1], | ||
| ), | ||
| ) * 180.0 / xp.pi / float(m) | ||
|
Comment on lines
+301
to
+308
|
||
|
|
||
| k_m = xp.sqrt(multipole_comps[1] ** 2 + multipole_comps[0] ** 2) | ||
|
|
||
| phi_m = xp.where(phi_m < -90.0 / m, phi_m + 360.0 / m, phi_m) | ||
|
|
||
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.
Add regression coverage for the new (0,0) elliptical-components branch. In particular, test that
axis_ratio_and_angle_from(ell_comps=(0.0, 0.0))returns finite values (axis_ratio ~ 1.0, angle ~ 0.0) for both NumPy and JAX backends (e.g.xp=jax.numpy) to ensure the original NaN/undefined-backend behavior can’t regress.