diff options
| author | Guillaume Horel <guillaume.horel@gmail.com> | 2017-11-17 10:22:20 -0500 |
|---|---|---|
| committer | Guillaume Horel <guillaume.horel@gmail.com> | 2017-11-17 10:22:20 -0500 |
| commit | b1fac2a46ca7e16248d73934937f54f750eecdb4 (patch) | |
| tree | b3c7becc311b32640165d709a360f25b28121165 | |
| parent | 57abfe947a0cc7b90fd5bcfb0c9f51e9f82d5a0a (diff) | |
| download | pyisda-b1fac2a46ca7e16248d73934937f54f750eecdb4.tar.gz | |
tie numpy array's life to the C++ vector life
| -rw-r--r-- | pyisda/credit_index.pyx | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/pyisda/credit_index.pyx b/pyisda/credit_index.pyx index bc3ee8f..c93b177 100644 --- a/pyisda/credit_index.pyx +++ b/pyisda/credit_index.pyx @@ -3,6 +3,7 @@ from libc.stdlib cimport malloc, free from libc.math cimport nan from libcpp.pair cimport pair from cython.operator cimport dereference as deref +from cpython cimport PyObject, Py_INCREF cimport cython from legs cimport (JpmcdsCdsContingentLegMake, JpmcdsCdsFeeLegMake, @@ -88,6 +89,8 @@ cdef class CurveList: cdef np.npy_intp shape = self.weights.size() cdef np.ndarray[np.float64_t] out = \ np.PyArray_SimpleNewFromData(1, &shape, np.NPY_DOUBLE, self.weights.data()) + out.base = <PyObject*>self + Py_INCREF(self) return out @property |
