From 6f1bbc1198993cb5017c3f68ae69f31a9fd4ec7f Mon Sep 17 00:00:00 2001 From: Guillaume Horel Date: Fri, 18 Jan 2019 15:44:07 -0500 Subject: log to stderr --- c_layer/cdsbootstrap.c | 2 +- pyisda/optim.pyx | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/c_layer/cdsbootstrap.c b/c_layer/cdsbootstrap.c index b0aa004..bbecc08 100644 --- a/c_layer/cdsbootstrap.c +++ b/c_layer/cdsbootstrap.c @@ -45,6 +45,6 @@ int cdsBootstrapPointFunction done: if (status != SUCCESS) - printf("Something went wrong: %f\n", hazardRate); + fprintf(stderr, "Something went wrong: %f\n", hazardRate); return status; } diff --git a/pyisda/optim.pyx b/pyisda/optim.pyx index bb1f722..b82a0d9 100644 --- a/pyisda/optim.pyx +++ b/pyisda/optim.pyx @@ -1,6 +1,6 @@ from libc.stdlib cimport abort from libc.stdlib cimport free, malloc -from libc.stdio cimport printf +from libc.stdio cimport fprintf, stderr from libc.math cimport exp, sqrt from .cdsone cimport JpmcdsStringToStubMethod, TStubMethod from .curve cimport (TCurve, YieldCurve, JpmcdsFreeTCurve, JpmcdsNewTCurve, @@ -130,13 +130,13 @@ cdef api double pv(double Z, void* ctx) nogil: 1e-10, # xacc */ 1e-10, # facc */ &h) != 0: - printf("Failed to find hazard rate for: %f\n", S) + fprintf(stderr, "Failed to find hazard rate for: %f\n", S) abort() params.cdsCurve.fArray[0].fRate = h if JpmcdsFeeLegPV(params.fl, params.cdsCurve.fBaseDate, params.stepinDate, params.cashSettleDate, params.discountCurve, params.cdsCurve, True, &coupon_leg_pv) != 0: - printf("Something went wrong\n") + fprintf(stderr, "Something went wrong\n") abort() return 0.3989422804014327 * exp(-0.5 * Z * Z) * \ ((S - params_ext.fixed_rate) * coupon_leg_pv - params_ext.G) @@ -182,13 +182,13 @@ def expected_pv(double[:] tilt, double[:] w, double S0, object ctx): 1e-10, # xacc */ 1e-10, # facc */ &h) != 0: - printf("Failed to find hazard rate for: %f\n", S) + fprintf(stderr, "Failed to find hazard rate for: %f\n", S) abort() params.cdsCurve.fArray[0].fRate = h if JpmcdsFeeLegPV(params.fl, params.cdsCurve.fBaseDate, params.stepinDate, params.cashSettleDate, params.discountCurve, params.cdsCurve, True, &coupon_leg_pv) != 0: - printf("Something went wrong\n") + fprintf(stderr, "Something went wrong\n") abort() r += w[i] * ((S - params_ext.fixed_rate) * coupon_leg_pv) return r -- cgit v1.2.3-70-g09d2