numpy
2.0.0
|
00001 #ifndef _NPY_PRIVATE__DATETIME_BUSDAYDEF_H_ 00002 #define _NPY_PRIVATE__DATETIME_BUSDAYDEF_H_ 00003 00004 /* 00005 * A list of holidays, which should be sorted, not contain any 00006 * duplicates or NaTs, and not include any days already excluded 00007 * by the associated weekmask. 00008 * 00009 * The data is manually managed with PyArray_malloc/PyArray_free. 00010 */ 00011 typedef struct { 00012 npy_datetime *begin, *end; 00013 } npy_holidayslist; 00014 00015 /* 00016 * This object encapsulates a weekmask and normalized holidays list, 00017 * so that the business day API can use this data without having 00018 * to normalize it repeatedly. All the data of this object is private 00019 * and cannot be modified from Python. Copies are made when giving 00020 * the weekmask and holidays data to Python code. 00021 */ 00022 typedef struct { 00023 PyObject_HEAD 00024 npy_holidayslist holidays; 00025 int busdays_in_weekmask; 00026 npy_bool weekmask[7]; 00027 } NpyBusDayCalendar; 00028 00029 #ifdef NPY_ENABLE_SEPARATE_COMPILATION 00030 extern NPY_NO_EXPORT PyTypeObject NpyBusDayCalendar_Type; 00031 #else 00032 NPY_NO_EXPORT PyTypeObject NpyBusDayCalendar_Type; 00033 #endif 00034 00035 00036 /* 00037 * Converts a Python input into a 7-element weekmask, where 0 means 00038 * weekend and 1 means business day. 00039 */ 00040 NPY_NO_EXPORT int 00041 PyArray_WeekMaskConverter(PyObject *weekmask_in, npy_bool *weekmask); 00042 00043 /* 00044 * Sorts the the array of dates provided in place and removes 00045 * NaT, duplicates and any date which is already excluded on account 00046 * of the weekmask. 00047 * 00048 * Returns the number of dates left after removing weekmask-excluded 00049 * dates. 00050 */ 00051 NPY_NO_EXPORT void 00052 normalize_holidays_list(npy_holidayslist *holidays, npy_bool *weekmask); 00053 00054 /* 00055 * Converts a Python input into a non-normalized list of holidays. 00056 * 00057 * IMPORTANT: This function can't do the normalization, because it doesn't 00058 * know the weekmask. You must call 'normalize_holiday_list' 00059 * on the result before using it. 00060 */ 00061 NPY_NO_EXPORT int 00062 PyArray_HolidaysConverter(PyObject *dates_in, npy_holidayslist *holidays); 00063 00064 00065 00066 #endif