numpy  2.0.0
src/multiarray/datetime_busdaycal.h File Reference

Go to the source code of this file.

Data Structures

struct  npy_holidayslist
struct  NpyBusDayCalendar

Functions

NPY_NO_EXPORT int PyArray_WeekMaskConverter (PyObject *weekmask_in, npy_bool *weekmask)
NPY_NO_EXPORT void normalize_holidays_list (npy_holidayslist *holidays, npy_bool *weekmask)
NPY_NO_EXPORT int PyArray_HolidaysConverter (PyObject *dates_in, npy_holidayslist *holidays)

Variables

NPY_NO_EXPORT PyTypeObject NpyBusDayCalendar_Type

Function Documentation

NPY_NO_EXPORT void normalize_holidays_list ( npy_holidayslist holidays,
npy_bool weekmask 
)
Sorts the array of dates provided in place and removes NaT, duplicates and any date which is already excluded on account of the weekmask.
Returns the number of dates left after removing weekmask-excluded dates.
Sort the dates
Sweep throught the array, eliminating unnecessary values
Skip any NaT or duplicate
Get the day of the week (1970-01-05 is Monday)
If the holiday falls on a possible business day, then keep it.
Adjust the end of the holidays array
NPY_NO_EXPORT int PyArray_HolidaysConverter ( PyObject *  dates_in,
npy_holidayslist holidays 
)
Converts a Python input into a non-normalized list of holidays.

IMPORTANT: This function can't do the normalization, because it doesn't
know the weekmask. You must call 'normalize_holiday_list' on the result before using it.
Make 'dates' into an array
Use the datetime dtype with generic units so it fills it in
This steals the datetime_dtype reference
Allocate the memory for the dates
Cast the data into a raw date array
NPY_NO_EXPORT int PyArray_WeekMaskConverter ( PyObject *  weekmask_in,
npy_bool weekmask 
)
Converts a Python input into a 7-element weekmask, where 0 means weekend and 1 means business day.
Make obj into an ASCII string if it is UNICODE
accept unicode input
Length 7 is a string like "1111100"
a string like "SatSun" or "Mon Tue Wed"
Something like [1,1,1,1,1,0,0]

References PyArray_Check, PyArray_NDIM, PyBytes_AsStringAndSize, and PyBytes_Check.


Variable Documentation