summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuillaume Horel <guillaume.horel@gmail.com>2018-08-22 11:06:33 -0400
committerGuillaume Horel <guillaume.horel@gmail.com>2018-08-22 11:06:33 -0400
commit290828965cee6db1c60749eea41115a63e2ce2e6 (patch)
tree98af9fd5d419ab4ef6b2c6ed97cfff31ae0b1cff
parent7e47e8a89ade557671756bfb04ac3eda0aa1d566 (diff)
downloadpyisda-290828965cee6db1c60749eea41115a63e2ce2e6.tar.gz
handle non inplace
-rw-r--r--pyisda/credit_index.pyx14
-rw-r--r--pyisda/curve.pxd1
2 files changed, 13 insertions, 2 deletions
diff --git a/pyisda/credit_index.pyx b/pyisda/credit_index.pyx
index b229cdd..f058839 100644
--- a/pyisda/credit_index.pyx
+++ b/pyisda/credit_index.pyx
@@ -507,9 +507,19 @@ cdef class CreditIndex(CurveList):
TDate maturity_c = pydate_to_TDate(maturity)
unsigned long mask = fill_mask(maturity_c, self._maturities, self._curves[0])
shared_ptr[TCurve] sc
+ TCurve* sc_orig, *sc_copy
+ size_t i
+ if inplace:
+ for sc in self._curves:
+ tweak_curve(sc.get(), sc.get(), epsilon, mask)
+ else:
+ for i in range(self._curves.size()):
+ sc_orig = self._curves[i].get()
+ sc_copy = JpmcdsCopyCurve(sc_orig)
+ tweak_curve(sc_orig, sc_copy, epsilon, mask)
+ self._curves[i].reset(sc_copy, JpmcdsFreeTCurve)
+
- for sc in self._curves:
- tweak_curve(sc.get(), sc.get(), epsilon, mask)
def survival_matrix(self, TDate[:] schedule):
cdef:
diff --git a/pyisda/curve.pxd b/pyisda/curve.pxd
index 6064c75..c30f502 100644
--- a/pyisda/curve.pxd
+++ b/pyisda/curve.pxd
@@ -202,6 +202,7 @@ cdef extern from "<memory>" namespace "std" nogil:
shared_ptr()
shared_ptr(T*, D)
T* get()
+ void reset(T*, D)
bool operator!()
long use_count()