summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuillaume Horel <guillaume.horel@gmail.com>2021-09-17 14:31:10 -0400
committerGuillaume Horel <guillaume.horel@gmail.com>2021-09-17 14:31:10 -0400
commit60ea3e046ddc0942677a51c3b6688885d755df8b (patch)
treed6a94bbfcafc3ba1646d3315fbb740da4bb576d6
parent2eef49e91679e84ca4b9d9d9f06d1cec6356f67c (diff)
downloadpyisda-60ea3e046ddc0942677a51c3b6688885d755df8b.tar.gz
pv is not defined in case of empty curves
- return NaN - as a side effect, do not segfault when epsilon != 0
-rw-r--r--pyisda/credit_index.pyx2
1 files changed, 2 insertions, 0 deletions
diff --git a/pyisda/credit_index.pyx b/pyisda/credit_index.pyx
index 2f90b01..0951f35 100644
--- a/pyisda/credit_index.pyx
+++ b/pyisda/credit_index.pyx
@@ -862,6 +862,8 @@ cdef double pv(const vector[shared_ptr[TCurve]]& curves,
size_t i = 0
double* recovery_rate
+ if curves.size() == 0:
+ return nan("")
if epsilon == 0.:
with parallel():
fl_pv = 0.