Skip to content

Commit 63ac010

Browse files
authored
Update utils.py (#648)
* Update utils.py fix trapezoid import * Update utils.py missed one trapz
1 parent 29c2eca commit 63ac010

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/cosmic/utils.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -855,7 +855,7 @@ def get_porb_norm(Z, close_logP=4.0, wide_logP=6.0, binfrac_tot_solar=0.66, Z_su
855855
normalization factor for kde for wide binaries
856856
'''
857857
from scipy.stats import norm
858-
from scipy.integrate import trapz
858+
from scipy.integrate import trapezoid
859859
from scipy.interpolate import interp1d
860860

861861
# fix to values used in Moe+19
@@ -866,7 +866,7 @@ def get_porb_norm(Z, close_logP=4.0, wide_logP=6.0, binfrac_tot_solar=0.66, Z_su
866866
logP_pdf = norm.pdf(log_P, loc=4.9, scale=2.3)
867867

868868
# set up the wide binary fraction inflection point
869-
norm_wide = binfrac_tot_solar/trapz(logP_pdf, log_P)
869+
norm_wide = binfrac_tot_solar/trapezoid(logP_pdf, log_P)
870870

871871
# set up the close binary fraction inflection point
872872
FeHclose = np.linspace(-3.0, 0.5, 100)
@@ -877,7 +877,7 @@ def get_porb_norm(Z, close_logP=4.0, wide_logP=6.0, binfrac_tot_solar=0.66, Z_su
877877
fclose_interp = interp1d(Zclose, fclose)
878878

879879
fclose_Z = fclose_interp(Z)
880-
norm_close = fclose_Z/trapz(logP_pdf[log_P < close_logP], log_P[log_P < close_logP])
880+
norm_close = fclose_Z/trapezoid(logP_pdf[log_P < close_logP], log_P[log_P < close_logP])
881881

882882
return norm_wide, norm_close
883883

@@ -904,7 +904,7 @@ def get_met_dep_binfrac(met):
904904
neval = 5000
905905

906906
from scipy.interpolate import interp1d
907-
from scipy.integrate import trapz
907+
from scipy.integrate import trapezoid
908908
from scipy.stats import norm
909909

910910
norm_wide, norm_close = get_porb_norm(met)
@@ -919,7 +919,7 @@ def get_met_dep_binfrac(met):
919919
np.linspace(wide_logP, logP_hi_lim, neval),])
920920
y_dat = np.hstack([prob_close, prob_interp_int(np.linspace(close_logP, wide_logP, neval)), prob_wide])
921921

922-
binfrac = trapz(y_dat, x_dat)/0.66 * 0.5
922+
binfrac = trapezoid(y_dat, x_dat)/0.66 * 0.5
923923

924924
return float(np.round(binfrac, 2))
925925

0 commit comments

Comments
 (0)