summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuillaume Horel <guillaume.horel@gmail.com>2019-10-10 16:57:12 -0400
committerGuillaume Horel <guillaume.horel@gmail.com>2019-10-10 16:57:12 -0400
commit0ee8969150cc0a68d920cd22499219916da60416 (patch)
treea0c354941303ea4c0623dd8cf1e3fa54246e4fab
parent5ae5babc87fcbf60d73a3fb06d0e16afda1c3f81 (diff)
downloadpyisda-0ee8969150cc0a68d920cd22499219916da60416.tar.gz
allow to set weights
-rw-r--r--pyisda/credit_index.pyx10
1 files changed, 10 insertions, 0 deletions
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()