Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
arg is None for arg in (rho_star, r_star, m_star)
) != 1:
raise ValueError(
"values must be provided for exactly two of "
"rho_star, m_star, and r_star"
)
if rho_star is not None and not implied_rho_star:
if has_unit(rho_star):
rho_star = tt.as_tensor_variable(
to_unit(rho_star, u.M_sun / u.R_sun ** 3)
)
else:
rho_star = tt.as_tensor_variable(rho_star) / gcc_per_sun
if r_star is not None:
r_star = tt.as_tensor_variable(to_unit(r_star, u.R_sun))
if m_star is not None:
m_star = tt.as_tensor_variable(to_unit(m_star, u.M_sun))
# Work out the stellar parameters
if rho_star is None:
rho_star = 3 * m_star / (4 * np.pi * r_star ** 3)
elif r_star is None:
r_star = (3 * m_star / (4 * np.pi * rho_star)) ** (1 / 3)
elif m_star is None:
m_star = 4 * np.pi * r_star ** 3 * rho_star / 3.0
# Work out the planet parameters
if a is None:
a = (
G_grav * (m_star + m_planet) * period ** 2 / (4 * np.pi ** 2)
) ** (1.0 / 3)
m_planet = tt.zeros_like(period)
# Compute the implied density if a and period are given
implied_rho_star = False
if a is not None and period is not None:
if rho_star is not None or m_star is not None:
raise ValueError(
"if both a and period are given, you can't "
"also define rho_star or m_star"
)
# Default to a stellar radius of 1 if not provided
if r_star is None:
r_star = tt.as_tensor_variable(1.0)
else:
r_star = tt.as_tensor_variable(to_unit(r_star, u.R_sun))
# Compute the implied mass via Kepler's 3rd law
m_tot = 4 * np.pi * np.pi * a ** 3 / (G_grav * period ** 2)
# Compute the implied density
m_star = m_tot - m_planet
vol_star = 4 * np.pi * r_star ** 3 / 3.0
rho_star = m_star / vol_star
implied_rho_star = True
# Make sure that the right combination of stellar parameters are given
if r_star is None and m_star is None:
r_star = 1.0
if rho_star is None:
m_star = 1.0
if (not implied_rho_star) and sum(
def _get_consistent_inputs(a, period, rho_star, r_star, m_star, m_planet):
if a is None and period is None:
raise ValueError(
"values must be provided for at least one of a " "and period"
)
if m_planet is not None:
m_planet = tt.as_tensor_variable(to_unit(m_planet, u.M_sun))
if a is not None:
a = tt.as_tensor_variable(to_unit(a, u.R_sun))
if m_planet is None:
m_planet = tt.zeros_like(a)
if period is not None:
period = tt.as_tensor_variable(to_unit(period, u.day))
if m_planet is None:
m_planet = tt.zeros_like(period)
# Compute the implied density if a and period are given
implied_rho_star = False
if a is not None and period is not None:
if rho_star is not None or m_star is not None:
raise ValueError(
"if both a and period are given, you can't "
def _get_consistent_inputs(a, period, rho_star, r_star, m_star, m_planet):
if a is None and period is None:
raise ValueError(
"values must be provided for at least one of a " "and period"
)
if m_planet is not None:
m_planet = tt.as_tensor_variable(to_unit(m_planet, u.M_sun))
if a is not None:
a = tt.as_tensor_variable(to_unit(a, u.R_sun))
if m_planet is None:
m_planet = tt.zeros_like(a)
if period is not None:
period = tt.as_tensor_variable(to_unit(period, u.day))
if m_planet is None:
m_planet = tt.zeros_like(period)
# Compute the implied density if a and period are given
implied_rho_star = False
if a is not None and period is not None:
if rho_star is not None or m_star is not None:
raise ValueError(
"if both a and period are given, you can't "
"also define rho_star or m_star"
)
def _get_consistent_inputs(a, period, rho_star, r_star, m_star, m_planet):
if a is None and period is None:
raise ValueError(
"values must be provided for at least one of a " "and period"
)
if m_planet is not None:
m_planet = tt.as_tensor_variable(to_unit(m_planet, u.M_sun))
if a is not None:
a = tt.as_tensor_variable(to_unit(a, u.R_sun))
if m_planet is None:
m_planet = tt.zeros_like(a)
if period is not None:
period = tt.as_tensor_variable(to_unit(period, u.day))
if m_planet is None:
m_planet = tt.zeros_like(period)
# Compute the implied density if a and period are given
implied_rho_star = False
if a is not None and period is not None:
if rho_star is not None or m_star is not None:
raise ValueError(
"if both a and period are given, you can't "
"also define rho_star or m_star"
)
# Default to a stellar radius of 1 if not provided
if r_star is None:
r_star = tt.as_tensor_variable(1.0)
else:
raise ValueError(
"values must be provided for exactly two of "
"rho_star, m_star, and r_star"
)
if rho_star is not None and not implied_rho_star:
if has_unit(rho_star):
rho_star = tt.as_tensor_variable(
to_unit(rho_star, u.M_sun / u.R_sun ** 3)
)
else:
rho_star = tt.as_tensor_variable(rho_star) / gcc_per_sun
if r_star is not None:
r_star = tt.as_tensor_variable(to_unit(r_star, u.R_sun))
if m_star is not None:
m_star = tt.as_tensor_variable(to_unit(m_star, u.M_sun))
# Work out the stellar parameters
if rho_star is None:
rho_star = 3 * m_star / (4 * np.pi * r_star ** 3)
elif r_star is None:
r_star = (3 * m_star / (4 * np.pi * rho_star)) ** (1 / 3)
elif m_star is None:
m_star = 4 * np.pi * r_star ** 3 * rho_star / 3.0
# Work out the planet parameters
if a is None:
a = (
G_grav * (m_star + m_planet) * period ** 2 / (4 * np.pi ** 2)
) ** (1.0 / 3)
elif period is None:
period = (