* This is the 'busday_offset' function exposed for calling * from Python. */
| 936 | * from Python. |
| 937 | */ |
| 938 | NPY_NO_EXPORT PyObject * |
| 939 | array_busday_offset(PyObject *NPY_UNUSED(self), |
| 940 | PyObject *args, PyObject *kwds) |
| 941 | { |
| 942 | static char *kwlist[] = {"dates", "offsets", "roll", |
| 943 | "weekmask", "holidays", "busdaycal", "out", NULL}; |
| 944 | |
| 945 | PyObject *dates_in = NULL, *offsets_in = NULL, *out_in = NULL; |
| 946 | |
| 947 | PyArrayObject *dates = NULL, *offsets = NULL, *out = NULL, *ret; |
| 948 | NPY_BUSDAY_ROLL roll = NPY_BUSDAY_RAISE; |
| 949 | npy_bool weekmask[7] = {2, 1, 1, 1, 1, 0, 0}; |
| 950 | NpyBusDayCalendar *busdaycal = NULL; |
| 951 | int i, busdays_in_weekmask; |
| 952 | npy_holidayslist holidays = {NULL, NULL}; |
| 953 | int allocated_holidays = 1; |
| 954 | |
| 955 | if (!PyArg_ParseTupleAndKeywords(args, kwds, |
| 956 | "OO|O&O&O&O!O:busday_offset", kwlist, |
| 957 | &dates_in, |
| 958 | &offsets_in, |
| 959 | &PyArray_BusDayRollConverter, &roll, |
| 960 | &PyArray_WeekMaskConverter, &weekmask[0], |
| 961 | &PyArray_HolidaysConverter, &holidays, |
| 962 | &NpyBusDayCalendar_Type, &busdaycal, |
| 963 | &out_in)) { |
| 964 | goto fail; |
| 965 | } |
| 966 | |
| 967 | /* Make sure only one of the weekmask/holidays and busdaycal is supplied */ |
| 968 | if (busdaycal != NULL) { |
| 969 | if (weekmask[0] != 2 || holidays.begin != NULL) { |
| 970 | PyErr_SetString(PyExc_ValueError, |
| 971 | "Cannot supply both the weekmask/holidays and the " |
| 972 | "busdaycal parameters to busday_offset()"); |
| 973 | goto fail; |
| 974 | } |
| 975 | |
| 976 | /* Indicate that the holidays weren't allocated by us */ |
| 977 | allocated_holidays = 0; |
| 978 | |
| 979 | /* Copy the private normalized weekmask/holidays data */ |
| 980 | holidays = busdaycal->holidays; |
| 981 | busdays_in_weekmask = busdaycal->busdays_in_weekmask; |
| 982 | memcpy(weekmask, busdaycal->weekmask, 7); |
| 983 | } |
| 984 | else { |
| 985 | /* |
| 986 | * Fix up the weekmask from the uninitialized |
| 987 | * signal value to a proper default. |
| 988 | */ |
| 989 | if (weekmask[0] == 2) { |
| 990 | weekmask[0] = 1; |
| 991 | } |
| 992 | |
| 993 | /* Count the number of business days in a week */ |
| 994 | busdays_in_weekmask = 0; |
| 995 | for (i = 0; i < 7; ++i) { |
nothing calls this directly
no test coverage detected