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 extern NPY_NO_EXPORT PyTypeObject NpyBusDayCalendar_Type; 00030 00031 00032 /* 00033 * Converts a Python input into a 7-element weekmask, where 0 means 00034 * weekend and 1 means business day. 00035 */ 00036 NPY_NO_EXPORT int 00037 PyArray_WeekMaskConverter(PyObject *weekmask_in, npy_bool *weekmask); 00038 00039 /* 00040 * Sorts the array of dates provided in place and removes 00041 * NaT, duplicates and any date which is already excluded on account 00042 * of the weekmask. 00043 * 00044 * Returns the number of dates left after removing weekmask-excluded 00045 * dates. 00046 */ 00047 NPY_NO_EXPORT void 00048 normalize_holidays_list(npy_holidayslist *holidays, npy_bool *weekmask); 00049 00050 /* 00051 * Converts a Python input into a non-normalized list of holidays. 00052 * 00053 * IMPORTANT: This function can't do the normalization, because it doesn't 00054 * know the weekmask. You must call 'normalize_holiday_list' 00055 * on the result before using it. 00056 */ 00057 NPY_NO_EXPORT int 00058 PyArray_HolidaysConverter(PyObject *dates_in, npy_holidayslist *holidays); 00059 00060 00061 00062 #endif