Skip to content

Commit

Permalink
Adding return typing for Mc_m1_to_m2, and only return the real root i…
Browse files Browse the repository at this point in the history
…n that function
  • Loading branch information
tsunhopang committed Oct 16, 2024
1 parent afe4e9a commit 1a67bf9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
8 changes: 4 additions & 4 deletions src/jimgw/single_event/transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,13 @@ def __init__(
m_1_turning_point_2 = Mc_q_to_m1_m2(self.M_c_max, self.q_max)[0]

def m2_range_regime_1(m_1: Float):
lower_bound = Mc_m1_to_m2(self.M_c_min, m_1)[0].real
lower_bound = Mc_m1_to_m2(self.M_c_min, m_1)
upper_bound = self.q_max * m_1
return [lower_bound, upper_bound]

def m2_range_regime_3(m_1: Float):
lower_bound = self.q_min * m_1
upper_bound = Mc_m1_to_m2(self.M_c_max, m_1)[0].real
upper_bound = Mc_m1_to_m2(self.M_c_max, m_1)
return [lower_bound, upper_bound]

if m_1_turning_point_2 >= m_1_turning_point_1:
Expand All @@ -112,8 +112,8 @@ def m2_range_regime_2(m_1: Float):
self.regime_2_mass_ratio,
lambda x: [self.q_min * x, self.q_max * x],
lambda x: [
Mc_m1_to_m2(self.M_c_min, x)[0].real,
Mc_m1_to_m2(self.M_c_max, x)[0].real,
Mc_m1_to_m2(self.M_c_min, x),
Mc_m1_to_m2(self.M_c_max, x),
],
m_1,
)
Expand Down
6 changes: 2 additions & 4 deletions src/jimgw/single_event/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def inner_product(
return 4.0 * jnp.real(trapezoid(integrand, dx=df))


def Mc_m1_to_m2(Mc: Float, m1: Float):
def Mc_m1_to_m2(Mc: Float, m1: Float) -> Float:

a = jnp.power(m1, 3.0)
b = 0.0
Expand All @@ -57,10 +57,8 @@ def Mc_m1_to_m2(Mc: Float, m1: Float):
U = jnp.cbrt(T)

x1 = (S + U) - (b / (3.0 * a))
x2 = -(S + U) / 2 - (b / (3.0 * a)) + (S - U) * jnp.sqrt(3.0) * 0.5j
x3 = -(S + U) / 2 - (b / (3.0 * a)) - (S - U) * jnp.sqrt(3.0) * 0.5j

return jnp.array([x1, x2, x3])
return x1.real


def m1_m2_to_M_q(m1: Float, m2: Float):
Expand Down

0 comments on commit 1a67bf9

Please sign in to comment.