Skip to content

Commit 434852b

Browse files
committed
better way to set up enum
1 parent f4e61fd commit 434852b

File tree

3 files changed

+11
-15
lines changed

3 files changed

+11
-15
lines changed

quantlib/time/calendars/_jointcalendar.pxd

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,7 @@
11
from libcpp.string cimport string
22

33
from quantlib.time._calendar cimport Calendar
4-
5-
6-
cdef extern from 'ql/time/calendars/jointcalendar.hpp' namespace 'QuantLib' nogil:
7-
8-
cdef enum JointCalendarRule:
9-
JoinHolidays # A date is a holiday for the joint calendar
10-
# if it is a holiday for any of the given calendars
11-
JoinBusinessDays # A date is a business day for the joint calendar
12-
# if it is a business day for any of the given calendars
4+
from .jointcalendar cimport JointCalendarRule
135

146
cdef extern from 'ql/time/calendars/jointcalendar.hpp' namespace 'QuantLib' nogil:
157
cdef cppclass JointCalendar(Calendar):
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
from quantlib.time.calendar cimport Calendar
22

3+
cdef extern from 'ql/time/calendars/jointcalendar.hpp' namespace 'QuantLib' nogil:
4+
5+
cpdef enum JointCalendarRule:
6+
JoinHolidays # A date is a holiday for the joint calendar
7+
# if it is a holiday for any of the given calendars
8+
JoinBusinessDays # A date is a business day for the joint calendar
9+
# if it is a business day for any of the given calendars
10+
311
cdef class JointCalendar(Calendar):
412
pass
513

quantlib/time/calendars/jointcalendar.pyx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,6 @@ cimport quantlib.time.calendars._jointcalendar as _jc
44
cimport quantlib.time._calendar as _cal
55
from quantlib.time.calendar cimport Calendar
66

7-
cpdef enum JointCalendarRule:
8-
JOINHOLIDAYS = _jc.JoinHolidays
9-
JOINBUSINESSDAYS = _jc.JoinBusinessDays
10-
117
cdef class JointCalendar(Calendar):
128
'''
139
Joint calendar
@@ -17,7 +13,7 @@ cdef class JointCalendar(Calendar):
1713
'''
1814

1915
@cython.cpp_locals(True)
20-
def __cinit__(self, Calendar c1, Calendar c2, int jc = JOINHOLIDAYS):
16+
def __cinit__(self, Calendar c1, Calendar c2, JointCalendarRule jc = JointCalendarRule.JoinHolidays):
2117
self._thisptr = _jc.JointCalendar(c1._thisptr,
2218
c2._thisptr,
23-
<_jc.JointCalendarRule> jc)
19+
jc)

0 commit comments

Comments
 (0)