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