From 85ddbe9646232aeeb8da6f2923659304159abb96 Mon Sep 17 00:00:00 2001 From: Thomas Ng Date: Tue, 23 Jul 2024 13:33:52 -0400 Subject: [PATCH 1/7] Remove unused variable --- src/jimgw/single_event/runManager.py | 1 - 1 file changed, 1 deletion(-) diff --git a/src/jimgw/single_event/runManager.py b/src/jimgw/single_event/runManager.py index aeb2304a..3f65166d 100644 --- a/src/jimgw/single_event/runManager.py +++ b/src/jimgw/single_event/runManager.py @@ -65,7 +65,6 @@ def jaxarray_representer(dumper: yaml.Dumper, data: ArrayImpl): @dataclass class SingleEventRun: seed: int - path: str detectors: list[str] priors: dict[ From a73759f870d16257e18556bf5f5893da1f705bc8 Mon Sep 17 00:00:00 2001 From: kazewong Date: Tue, 23 Jul 2024 16:15:11 -0400 Subject: [PATCH 2/7] Fixing pre-commit issue. Before this commit, typechecker has issue with the logsumexp input type at line 710. The reason is @jit return a wrapped type, which does not match logsumexp. Removing @jit in log_i0 in utils.py resolve this issue. In general, util functions should not be jitted until needed during runtime --- src/jimgw/single_event/likelihood.py | 2 +- src/jimgw/single_event/utils.py | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/jimgw/single_event/likelihood.py b/src/jimgw/single_event/likelihood.py index 6f2a2361..f10aeed1 100644 --- a/src/jimgw/single_event/likelihood.py +++ b/src/jimgw/single_event/likelihood.py @@ -541,8 +541,8 @@ def compute_coefficients(data, h_ref, psd, freqs, f_bins, f_bins_center): def maximize_likelihood( self, - bounds: Float[Array, " n_dim 2"], prior: Prior, + bounds: Float[Array, " n_dim 2"], popsize: int = 100, n_steps: int = 2000, ): diff --git a/src/jimgw/single_event/utils.py b/src/jimgw/single_event/utils.py index 72ef5e36..2eb2a763 100644 --- a/src/jimgw/single_event/utils.py +++ b/src/jimgw/single_event/utils.py @@ -300,8 +300,7 @@ def zenith_azimuth_to_ra_dec( return ra, dec -@jit -def log_i0(x): +def log_i0(x: Float[Array, " n"]) -> Float[Array, " n"]: """ A numerically stable method to evaluate log of a modified Bessel function of order 0. From 2f0b1aeee50b156160e816e9dc78b6f58f5f80f7 Mon Sep 17 00:00:00 2001 From: kazewong Date: Tue, 23 Jul 2024 16:16:17 -0400 Subject: [PATCH 3/7] Removing @jit in utils function --- src/jimgw/single_event/utils.py | 9 --------- 1 file changed, 9 deletions(-) diff --git a/src/jimgw/single_event/utils.py b/src/jimgw/single_event/utils.py index 2eb2a763..9d4d664e 100644 --- a/src/jimgw/single_event/utils.py +++ b/src/jimgw/single_event/utils.py @@ -5,7 +5,6 @@ from jaxtyping import Array, Float -@jit def inner_product( h1: Float[Array, " n_sample"], h2: Float[Array, " n_sample"], @@ -39,7 +38,6 @@ def inner_product( return 4.0 * jnp.real(trapezoid(integrand, dx=df)) -@jit def m1m2_to_Mq(m1: Float, m2: Float): """ Transforming the primary mass m1 and secondary mass m2 to the Total mass M @@ -64,7 +62,6 @@ def m1m2_to_Mq(m1: Float, m2: Float): return M_tot, q -@jit def Mq_to_m1m2(trans_M_tot: Float, trans_q: Float): """ Transforming the Total mass M and mass ratio q to the primary mass m1 and @@ -91,7 +88,6 @@ def Mq_to_m1m2(trans_M_tot: Float, trans_q: Float): return m1, m2 -@jit def Mc_q_to_m1m2(Mc: Float, q: Float) -> tuple[Float, Float]: """ Transforming the chirp mass Mc and mass ratio q to the primary mass m1 and @@ -118,7 +114,6 @@ def Mc_q_to_m1m2(Mc: Float, q: Float) -> tuple[Float, Float]: return m1, m2 -@jit def ra_dec_to_theta_phi(ra: Float, dec: Float, gmst: Float) -> tuple[Float, Float]: """ Transforming the right ascension ra and declination dec to the polar angle @@ -145,7 +140,6 @@ def ra_dec_to_theta_phi(ra: Float, dec: Float, gmst: Float) -> tuple[Float, Floa return theta, phi -@jit def euler_rotation(delta_x: tuple[Float, Float, Float]): """ Calculate the rotation matrix mapping the vector (0, 0, 1) to delta_x @@ -189,7 +183,6 @@ def euler_rotation(delta_x: tuple[Float, Float, Float]): return rotation -@jit def zenith_azimuth_to_theta_phi( zenith: Float, azimuth: Float, delta_x: tuple[Float, Float, Float] ) -> tuple[Float, Float]: @@ -241,7 +234,6 @@ def zenith_azimuth_to_theta_phi( return theta, phi -@jit def theta_phi_to_ra_dec(theta: Float, phi: Float, gmst: Float) -> tuple[Float, Float]: """ Transforming the polar angle and azimuthal angle to right ascension and declination. @@ -267,7 +259,6 @@ def theta_phi_to_ra_dec(theta: Float, phi: Float, gmst: Float) -> tuple[Float, F return ra, dec -@jit def zenith_azimuth_to_ra_dec( zenith: Float, azimuth: Float, gmst: Float, delta_x: tuple[Float, Float, Float] ) -> tuple[Float, Float]: From a84a659cbf0ab3214007fcd23fdd281423bc0e27 Mon Sep 17 00:00:00 2001 From: kazewong Date: Tue, 23 Jul 2024 16:25:32 -0400 Subject: [PATCH 4/7] update utils function zenith_azimuth_to_ra_dec --- src/jimgw/single_event/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/jimgw/single_event/utils.py b/src/jimgw/single_event/utils.py index 9d4d664e..ad6e3966 100644 --- a/src/jimgw/single_event/utils.py +++ b/src/jimgw/single_event/utils.py @@ -184,7 +184,7 @@ def euler_rotation(delta_x: tuple[Float, Float, Float]): def zenith_azimuth_to_theta_phi( - zenith: Float, azimuth: Float, delta_x: tuple[Float, Float, Float] + zenith: Float, azimuth: Float, delta_x: Float[Array, " 3"] ) -> tuple[Float, Float]: """ Transforming the azimuthal angle and zenith angle in Earth frame to the polar angle and azimuthal angle in sky frame. From 89f98395c07df8fea62b0e3fa85a76215e70f667 Mon Sep 17 00:00:00 2001 From: kazewong Date: Tue, 23 Jul 2024 16:26:58 -0400 Subject: [PATCH 5/7] update ruff.toml --- ruff.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/ruff.toml b/ruff.toml index bf64e2d0..5c56951b 100644 --- a/ruff.toml +++ b/ruff.toml @@ -1 +1,2 @@ +[lint] ignore = ["F722"] \ No newline at end of file From 0080e286a99f24945931406620f6a14de2ce5053 Mon Sep 17 00:00:00 2001 From: kazewong Date: Tue, 23 Jul 2024 16:27:37 -0400 Subject: [PATCH 6/7] deprecated python 3.9 --- .github/workflows/python-package.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index 44d9bb6b..4806efed 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -16,7 +16,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: ["3.9", "3.10", "3.11"] + python-version: ["3.10", "3.11"] steps: - uses: actions/checkout@v3 From 602c164ca8bbcd951bda95acb23ba4a4a83f5151 Mon Sep 17 00:00:00 2001 From: kazewong Date: Tue, 23 Jul 2024 16:33:22 -0400 Subject: [PATCH 7/7] Convert the rest of the type conflicts --- src/jimgw/single_event/utils.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/jimgw/single_event/utils.py b/src/jimgw/single_event/utils.py index ad6e3966..3f0decce 100644 --- a/src/jimgw/single_event/utils.py +++ b/src/jimgw/single_event/utils.py @@ -1,5 +1,4 @@ import jax.numpy as jnp -from jax import jit from jax.scipy.integrate import trapezoid from jax.scipy.special import i0e from jaxtyping import Array, Float @@ -140,7 +139,7 @@ def ra_dec_to_theta_phi(ra: Float, dec: Float, gmst: Float) -> tuple[Float, Floa return theta, phi -def euler_rotation(delta_x: tuple[Float, Float, Float]): +def euler_rotation(delta_x: Float[Array, " 3"]): """ Calculate the rotation matrix mapping the vector (0, 0, 1) to delta_x while preserving the origin of the azimuthal angle. @@ -260,7 +259,7 @@ def theta_phi_to_ra_dec(theta: Float, phi: Float, gmst: Float) -> tuple[Float, F def zenith_azimuth_to_ra_dec( - zenith: Float, azimuth: Float, gmst: Float, delta_x: tuple[Float, Float, Float] + zenith: Float, azimuth: Float, gmst: Float, delta_x: Float[Array, " 3"] ) -> tuple[Float, Float]: """ Transforming the azimuthal angle and zenith angle in Earth frame to right ascension and declination.