Commit 5566d9d0 authored by Gregory Ashton's avatar Gregory Ashton

Merge branch 'fix-to-floats' into 'master'

Further fix to encapsulation functions

See merge request !297
parents 2569a765 ba8b7c81
Pipeline #40962 passed with stage
in 10 minutes and 59 seconds
......@@ -596,21 +596,25 @@ def plot_skymap(result, center='120d -40d', nside=512):
fig.savefig('{}/{}_skymap.png'.format(result.outdir, result.label))
def convert_args_list_to_float(*args_list):
""" Converts inputs to floats, returns a list in the same order as the input"""
try:
args_list = [float(arg) for arg in args_list]
except ValueError:
raise ValueError("Unable to convert inputs to floats")
return args_list
def lalsim_SimInspiralTransformPrecessingNewInitialConditions(
theta_jn, phi_jl, tilt_1, tilt_2, phi_12, a_1, a_2, mass_1, mass_2,
reference_frequency, phase):
for arg in (theta_jn, phi_jl, tilt_1, tilt_2, phi_12, a_1, a_2, mass_1,
mass_2, reference_frequency, phase):
try:
arg = float(arg)
except ValueError:
raise ValueError("Unable to convert inputs to floats")
return lalsim.SimInspiralTransformPrecessingNewInitialConditions(
args_list = convert_args_list_to_float(
theta_jn, phi_jl, tilt_1, tilt_2, phi_12, a_1, a_2, mass_1, mass_2,
reference_frequency, phase)
return lalsim.SimInspiralTransformPrecessingNewInitialConditions(*args_list)
def lalsim_GetApproximantFromString(waveform_approximant):
if isinstance(waveform_approximant, str):
......@@ -626,15 +630,15 @@ def lalsim_SimInspiralChooseFDWaveform(
minimum_frequency, maximum_frequency, reference_frequency,
waveform_dictionary, approximant):
for arg in (mass_1, mass_2, spin_1x, spin_1y, spin_1z, spin_2x, spin_2y,
spin_2z, luminosity_distance, iota, phase,
longitude_ascending_nodes, eccentricity, mean_per_ano,
delta_frequency, minimum_frequency, maximum_frequency,
reference_frequency):
try:
arg = float(arg)
except ValueError:
raise ValueError("Unable to convert inputs to floats")
# Convert values to floats
[mass_1, mass_2, spin_1x, spin_1y, spin_1z, spin_2x, spin_2y, spin_2z,
luminosity_distance, iota, phase, longitude_ascending_nodes,
eccentricity, mean_per_ano, delta_frequency, minimum_frequency,
maximum_frequency, reference_frequency] = convert_args_list_to_float(
mass_1, mass_2, spin_1x, spin_1y, spin_1z, spin_2x, spin_2y, spin_2z,
luminosity_distance, iota, phase, longitude_ascending_nodes,
eccentricity, mean_per_ano, delta_frequency, minimum_frequency,
maximum_frequency, reference_frequency)
# Note, this is the approximant number returns by GetApproximantFromString
if isinstance(approximant, int) is False:
......@@ -662,9 +666,9 @@ def lalsim_SimInspiralWaveformParamsInsertTidalLambda1(
def lalsim_SimInspiralWaveformParamsInsertTidalLambda2(
waveform_dictionary, lambda_2):
try:
lambda_1 = float(lambda_2)
lambda_2 = float(lambda_2)
except ValueError:
raise ValueError("Unable to convert lambda_2 to float")
return lalsim.SimInspiralWaveformParamsInsertTidalLambda1(
waveform_dictionary, lambda_1)
return lalsim.SimInspiralWaveformParamsInsertTidalLambda2(
waveform_dictionary, lambda_2)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment