summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuillaume Horel <guillaume.horel@gmail.com>2023-04-25 13:52:35 -0400
committerGuillaume Horel <guillaume.horel@gmail.com>2023-04-25 13:53:41 -0400
commit94a225203e36b0d9da5b39daab765d465bed76f1 (patch)
treeb06403bc9587128c9e113823fd42bc1a4d6d38c1
parentbd353e0363b66ff8498c914e3c941318739fef35 (diff)
downloadpyisda-94a225203e36b0d9da5b39daab765d465bed76f1.tar.gz
add some noexcept
-rw-r--r--pyisda/credit_index.pxd2
-rw-r--r--pyisda/credit_index.pyx4
-rw-r--r--pyisda/curve.pxd8
-rw-r--r--pyisda/curve.pyx12
-rw-r--r--pyisda/legs.pxd2
-rw-r--r--pyisda/legs.pyx2
-rw-r--r--pyisda/optim.pyx2
7 files changed, 16 insertions, 16 deletions
diff --git a/pyisda/credit_index.pxd b/pyisda/credit_index.pxd
index db446bc..57fb8a4 100644
--- a/pyisda/credit_index.pxd
+++ b/pyisda/credit_index.pxd
@@ -23,4 +23,4 @@ cdef class CreditIndex(CurveList):
cdef readonly string cal_file
-cdef CurveList_copy(CurveList orig, CurveList copy)
+cdef CurveList_copy(CurveList orig, CurveList copy) noexcept
diff --git a/pyisda/credit_index.pyx b/pyisda/credit_index.pyx
index b7f1d74..4730258 100644
--- a/pyisda/credit_index.pyx
+++ b/pyisda/credit_index.pyx
@@ -29,10 +29,10 @@ cimport cython
ctypedef TFeeLeg* TFeeLeg_ptr
ctypedef TContingentLeg* TContingentLeg_ptr
-cdef inline void char_free(char* ptr) nogil:
+cdef inline void char_free(char* ptr) noexcept nogil:
free(ptr)
-cdef CurveList_copy(CurveList orig, CurveList copy):
+cdef CurveList_copy(CurveList orig, CurveList copy) noexcept:
cdef:
char* buf
char* new_buf
diff --git a/pyisda/curve.pxd b/pyisda/curve.pxd
index 577961a..8fb6733 100644
--- a/pyisda/curve.pxd
+++ b/pyisda/curve.pxd
@@ -227,11 +227,11 @@ cdef class SpreadCurve(Curve):
cdef inline double* recovery_rates_ptr(self) nogil
cdef inline char* name(self) nogil
-cdef fArray_to_list(const TRatePt* fArray, int fNumItems)
+cdef fArray_to_list(const TRatePt* fArray, int fNumItems) noexcept
cdef void tweak_curve(const TCurve* sc, TCurve* sc_tweaked, double epsilon,
- unsigned long mask) nogil
+ unsigned long mask) noexcept nogil
-cdef uint16_t name_offset_from_buf(const char* buf) nogil
+cdef uint16_t name_offset_from_buf(const char* buf) noexcept nogil
-cdef size_t buf_size(int n, int ticker_len) nogil
+cdef size_t buf_size(int n, int ticker_len) noexcept nogil
diff --git a/pyisda/curve.pyx b/pyisda/curve.pyx
index b5c2d5d..90df782 100644
--- a/pyisda/curve.pyx
+++ b/pyisda/curve.pyx
@@ -41,7 +41,7 @@ cdef int SUCCESS = 0
cdef inline void double_free(double* ptr) nogil:
free(ptr)
-cdef inline void char_free(char* ptr) nogil:
+cdef inline void char_free(char* ptr) noexcept nogil:
free(ptr)
cdef double survival_prob(const TCurve* curve, TDate start_date, TDate maturity_date, double eps, bint log) nogil:
@@ -307,7 +307,7 @@ cdef class Curve(object):
const TCurve* curve = self.get_TCurve()
return JpmcdsZeroRate(curve, pydate_to_TDate(d))
-cdef fArray_to_list(const TRatePt* fArray, int fNumItems):
+cdef fArray_to_list(const TRatePt* fArray, int fNumItems) noexcept:
cdef size_t i
cdef list l = []
for i in range(fNumItems):
@@ -549,7 +549,7 @@ cdef class YieldCurve(Curve):
@cython.cdivision(True)
cdef void tweak_curve(const TCurve* sc, TCurve* sc_tweaked, double epsilon,
- unsigned long mask) nogil:
+ unsigned long mask) noexcept nogil:
## We want to tweak in the forward space, so we convert the hazard rates
## into forward rates and then back
cdef double h1, h2, t1, t2, c
@@ -567,10 +567,10 @@ cdef void tweak_curve(const TCurve* sc, TCurve* sc_tweaked, double epsilon,
h1 = h2
t1 = t2
-cdef size_t buf_size(int n, int ticker_len) nogil:
+cdef size_t buf_size(int n, int ticker_len) noexcept nogil:
return sizeof(TCurve) + n * sizeof(TRatePt) + n * sizeof(double) + sizeof(TDate) + sizeof(DocClause) + sizeof(Seniority) + ticker_len + 1
-cdef uint16_t name_offset_from_buf(const char* buf) nogil:
+cdef uint16_t name_offset_from_buf(const char* buf) noexcept nogil:
cdef TCurve* curve = <TCurve*>buf
cdef int n = curve.fNumItems
return sizeof(TCurve) + n * (sizeof(TRatePt) + sizeof(double)) + sizeof(TDate)
@@ -1009,7 +1009,7 @@ cdef class SpreadCurve(Curve):
@cython.cdivision(True)
@cython.boundscheck(False)
-cdef void _fill_curve(const TCurve* sc, const TDate* end_dates, int n_dates, char* buf) nogil:
+cdef void _fill_curve(const TCurve* sc, const TDate* end_dates, int n_dates, char* buf) noexcept nogil:
cdef:
size_t i
TDate base_date = sc.fBaseDate
diff --git a/pyisda/legs.pxd b/pyisda/legs.pxd
index 6a31c17..3ff8545 100644
--- a/pyisda/legs.pxd
+++ b/pyisda/legs.pxd
@@ -112,4 +112,4 @@ cdef class FeeLeg:
cdef TFeeLeg* _thisptr
-cdef void fee_leg_copy(TFeeLeg* orig, TFeeLeg* copy) nogil
+cdef void fee_leg_copy(TFeeLeg* orig, TFeeLeg* copy) noexcept nogil
diff --git a/pyisda/legs.pyx b/pyisda/legs.pyx
index a7f6ab2..97537ca 100644
--- a/pyisda/legs.pyx
+++ b/pyisda/legs.pyx
@@ -214,7 +214,7 @@ cdef class FeeLeg:
JpmcdsFeeLegFree(self._thisptr)
-cdef void fee_leg_copy(const TFeeLeg* orig, TFeeLeg* copy) nogil:
+cdef void fee_leg_copy(const TFeeLeg* orig, TFeeLeg* copy) noexcept nogil:
cdef int n = orig.nbDates
copy.nbDates = n
copy.notional = orig.notional
diff --git a/pyisda/optim.pyx b/pyisda/optim.pyx
index ee75f87..9da95bf 100644
--- a/pyisda/optim.pyx
+++ b/pyisda/optim.pyx
@@ -107,7 +107,7 @@ def init_context(YieldCurve yc not None, trade_date, value_date, start_date,
@cython.cdivision(True)
-cdef api double pv(double Z, void* ctx) nogil except NAN:
+cdef api double pv(double Z, void* ctx) except NAN nogil:
cdef:
my_ctx* params_ext = <my_ctx*>ctx
cds_bootstrap_ctx* params = &params_ext.params