From a972241805699489b2d827a95f65ee9ebb9551b0 Mon Sep 17 00:00:00 2001 From: Guillaume Horel Date: Fri, 17 Nov 2017 15:59:52 -0500 Subject: slightly faster --- pyisda/credit_index.pyx | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/pyisda/credit_index.pyx b/pyisda/credit_index.pyx index 8bfc769..ab78ce7 100644 --- a/pyisda/credit_index.pyx +++ b/pyisda/credit_index.pyx @@ -16,10 +16,13 @@ from cdsone cimport JpmcdsStringToStubMethod, TStubMethod from date cimport ACT_365F cimport numpy as np np.import_array() +import numpy as np import pandas as pd cdef class CurveList: - def __init__(self, list curves, double[:] weights=None): + + @cython.initializedcheck(False) + def __init__(self, list curves not None, double[:] weights=None): cdef: SpreadCurve sc size_t i @@ -91,8 +94,8 @@ cdef class CurveList: @property def weights(self): 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()) + cdef np.ndarray out = \ + np.PyArray_SimpleNewFromData(1, &shape, np.NPY_DOUBLE, self.weights.data()) out.base = self Py_INCREF(self) return out @@ -116,7 +119,7 @@ cdef class CurveList: return r @curves.setter - def curves(self, list l): + def curves(self, list l not None): cdef: size_t len_l = len(l) size_t i -- cgit v1.2.3-70-g09d2