From 6640f53b9d25b041dfa410579119df4910fd915d Mon Sep 17 00:00:00 2001 From: Guillaume Horel Date: Thu, 13 Apr 2017 11:18:45 -0400 Subject: add __hash__ method --- pyisda/curve.pyx | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/pyisda/curve.pyx b/pyisda/curve.pyx index cbe2174..730e066 100644 --- a/pyisda/curve.pyx +++ b/pyisda/curve.pyx @@ -34,7 +34,7 @@ cdef class Curve(object): def __getstate__(self): cdef TCurve* curve = self._thisptr.get() - cdef int num_items = curve.fNumItems; + cdef int num_items = curve.fNumItems return (num_items, (curve.fArray)[:sizeof(TRatePt)*num_items], curve.fBaseDate, @@ -59,6 +59,15 @@ cdef class Curve(object): new_curve.fDayCountConv = dcc self._thisptr = make_shared(new_curve) + def __hash__(self): + cdef TCurve* curve = self._thisptr.get() + cdef int num_items = curve.fNumItems + return hash((num_items, + (curve.fArray)[:sizeof(TRatePt)*num_items], + curve.fBaseDate, + curve.fBasis, + curve.fDayCountConv)) + def inspect(self): """ method to inspect the content of the C struct -- cgit v1.2.3-70-g09d2