From 0ee8969150cc0a68d920cd22499219916da60416 Mon Sep 17 00:00:00 2001 From: Guillaume Horel Date: Thu, 10 Oct 2019 16:57:12 -0400 Subject: allow to set weights --- pyisda/credit_index.pyx | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/pyisda/credit_index.pyx b/pyisda/credit_index.pyx index da9a177..a3c6fe9 100644 --- a/pyisda/credit_index.pyx +++ b/pyisda/credit_index.pyx @@ -133,6 +133,16 @@ cdef class CurveList: Py_INCREF(self) return out + @weights.setter + def weights(self, double[::1] val): + if val.shape[0] != self._weights.size(): + raise ValueError("size mismatch") + + cdef size_t i + for i in range(self.weights.size()): + self.weights[i] = val[i] + + @property def tickers(self): cdef np.npy_intp shape = self.names.size() -- cgit v1.2.3-70-g09d2