diff options
| author | Guillaume Horel <guillaume.horel@gmail.com> | 2023-04-27 15:53:36 -0400 |
|---|---|---|
| committer | Guillaume Horel <guillaume.horel@gmail.com> | 2023-04-27 15:53:36 -0400 |
| commit | 3b79c5de75370c6fd30adbfe72c1e70d9ffe791c (patch) | |
| tree | c19ad6314a15b3ccabe0a266d77dd471d55de6b7 | |
| parent | c5002a58ffb4b3d25941e146dfb3ce6d4391c1de (diff) | |
| download | pyisda-3b79c5de75370c6fd30adbfe72c1e70d9ffe791c.tar.gz | |
use uint16_t instead of short
| -rw-r--r-- | pyisda/curve.pyx | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/pyisda/curve.pyx b/pyisda/curve.pyx index 6dc66f1..104a98d 100644 --- a/pyisda/curve.pyx +++ b/pyisda/curve.pyx @@ -2,6 +2,7 @@ from cython.operator import dereference as deref, preincrement as preinc from cpython.bytes cimport PyBytes_FromStringAndSize, PyBytes_AS_STRING from libc.math cimport log1p, log, exp, isnan +from libc.stdint cimport uint16_t from libc.string cimport strcpy, strncpy, strlen from .date cimport (JpmcdsStringToDateInterval, pydate_to_TDate, dcc, JpmcdsDateIntervalToFreq, JpmcdsDateFwdThenAdjust, TDate_to_pydate, @@ -94,7 +95,7 @@ cdef class Curve(object): elif fmt == 0: r = self.buf.get()[:self.buf_size] elif fmt == 2: - packed_size = sizeof(TCurve) + curve.fNumItems * (sizeof(double) + sizeof(short)) + packed_size = sizeof(TCurve) + curve.fNumItems * (sizeof(double) + sizeof(uint16_t)) r = PyBytes_FromStringAndSize(NULL, packed_size) dst = PyBytes_AS_STRING(r) src = <char*>curve @@ -102,8 +103,8 @@ cdef class Curve(object): src += sizeof(TCurve) dst += sizeof(TCurve) for i in range(curve.fNumItems): - (<short*>dst)[i] = (<TRatePt*>src)[i].fDate - curve.fBaseDate - (<double*>(dst + curve.fNumItems * sizeof(short)))[i] = (<TRatePt*>src)[i].fRate + (<uint16_t*>dst)[i] = (<TRatePt*>src)[i].fDate - curve.fBaseDate + (<double*>(dst + curve.fNumItems * sizeof(uint16_t)))[i] = (<TRatePt*>src)[i].fRate return r def __getstate__(self): |
