diff options
-rw-r--r-- | doc/source/reference/routines.datetime.rst | 2 | ||||
-rw-r--r-- | numpy/add_newdocs.py | 44 | ||||
-rw-r--r-- | numpy/core/SConscript | 2 | ||||
-rw-r--r-- | numpy/core/code_generators/genapi.py | 2 | ||||
-rw-r--r-- | numpy/core/numerictypes.py | 4 | ||||
-rw-r--r-- | numpy/core/setup.py | 2 | ||||
-rw-r--r-- | numpy/core/src/multiarray/datetime_busday.c | 56 | ||||
-rw-r--r-- | numpy/core/src/multiarray/datetime_busdaycal.c (renamed from numpy/core/src/multiarray/datetime_busdaydef.c) | 42 | ||||
-rw-r--r-- | numpy/core/src/multiarray/datetime_busdaycal.h (renamed from numpy/core/src/multiarray/datetime_busdaydef.h) | 7 | ||||
-rw-r--r-- | numpy/core/src/multiarray/multiarraymodule.c | 13 | ||||
-rw-r--r-- | numpy/core/src/multiarray/multiarraymodule_onefile.c | 2 | ||||
-rw-r--r-- | numpy/core/tests/test_datetime.py | 38 |
12 files changed, 107 insertions, 107 deletions
diff --git a/doc/source/reference/routines.datetime.rst b/doc/source/reference/routines.datetime.rst index d8517bd39..aab6f1694 100644 --- a/doc/source/reference/routines.datetime.rst +++ b/doc/source/reference/routines.datetime.rst @@ -13,7 +13,7 @@ Business Day Functions .. autosummary:: :toctree: generated/ - busdaydef + busdaycalendar is_busday busday_offset busday_count diff --git a/numpy/add_newdocs.py b/numpy/add_newdocs.py index 270147ae2..f1be98bd2 100644 --- a/numpy/add_newdocs.py +++ b/numpy/add_newdocs.py @@ -5940,12 +5940,13 @@ add_newdoc('numpy.core.multiarray', 'dtype', ('newbyteorder', # ############################################################################## -add_newdoc('numpy.core.multiarray', 'busdaydef', +add_newdoc('numpy.core.multiarray', 'busdaycalendar', """ - busdaydef(weekmask='1111100', holidays=None) + busdaycalendar(weekmask='1111100', holidays=None) - An object that efficiently stores information defining business - days for the business day-related functions. + A business day calendar object that efficiently stores + information defining business days for the business + day-related functions. Parameters ---------- @@ -5965,8 +5966,8 @@ add_newdoc('numpy.core.multiarray', 'busdaydef', Returns ------- - out : busdaydef - A business day definition object containing the specified + out : busdaycalendar + A business day calendar object containing the specified weekmask and holidays. See Also @@ -5983,7 +5984,8 @@ add_newdoc('numpy.core.multiarray', 'busdaydef', Examples -------- >>> # Some important days in July - ... bdd = np.busdaydef(holidays=['2011-07-01', '2011-07-04', '2011-07-17']) + ... bdd = np.busdaycalendar( + ... holidays=['2011-07-01', '2011-07-04', '2011-07-17']) >>> # Default is Monday to Friday weekdays ... bdd.weekmask array([ True, True, True, True, True, False, False], dtype='bool') @@ -5992,15 +5994,15 @@ add_newdoc('numpy.core.multiarray', 'busdaydef', array(['2011-07-01', '2011-07-04'], dtype='datetime64[D]') """) -add_newdoc('numpy.core.multiarray', 'busdaydef', ('weekmask', +add_newdoc('numpy.core.multiarray', 'busdaycalendar', ('weekmask', """A copy of the seven-element boolean mask indicating valid business days.""")) -add_newdoc('numpy.core.multiarray', 'busdaydef', ('holidays', +add_newdoc('numpy.core.multiarray', 'busdaycalendar', ('holidays', """A copy of the holiday array indicating blacked out business days.""")) add_newdoc('numpy.core.multiarray', 'is_busday', """ - is_busday(dates, weekmask='1111100', holidays=None, busdaydef=None, out=None) + is_busday(dates, weekmask='1111100', holidays=None, busdaycal=None, out=None) Calculates which of the given dates are valid business days, and which are not. @@ -6022,8 +6024,8 @@ add_newdoc('numpy.core.multiarray', 'is_busday', as business days. They may be specified in any order, and NaT (not-a-time) dates are ignored. Internally, this list is normalized into a form suited for fast business day calculations. - busdaydef : busdaydef - A `busdaydef` object which specifies the business days. If this + busdaycal : busdaycalendar + A `busdaycalendar` object which specifies the business days. If this parameter is provided, neither weekmask nor holidays may be provided. out : array of bool @@ -6037,7 +6039,7 @@ add_newdoc('numpy.core.multiarray', 'is_busday', See Also -------- - busdaydef: An object for efficiently specifying which are business days. + busdaycalendar: An object for efficiently specifying which are business days. busday_offset : Applies an offset counted in business days. busday_count : Counts how many business days are in a half-open date range. @@ -6051,7 +6053,7 @@ add_newdoc('numpy.core.multiarray', 'is_busday', add_newdoc('numpy.core.multiarray', 'busday_offset', """ - busday_offset(dates, offsets, roll='raise', weekmask='1111100', holidays=None, busdaydef=None, out=None) + busday_offset(dates, offsets, roll='raise', weekmask='1111100', holidays=None, busdaycal=None, out=None) First adjusts the date to fall on a business day according to the ``roll`` rule, then applies offsets to the given dates @@ -6092,8 +6094,8 @@ add_newdoc('numpy.core.multiarray', 'busday_offset', as business days. They may be specified in any order, and NaT (not-a-time) dates are ignored. Internally, this list is normalized into a form suited for fast business day calculations. - busdaydef : busdaydef - A `busdaydef` object which specifies the business days. If this + busdaycal : busdaycalendar + A `busdaycalendar` object which specifies the business days. If this parameter is provided, neither weekmask nor holidays may be provided. out : array of datetime64[D] @@ -6107,7 +6109,7 @@ add_newdoc('numpy.core.multiarray', 'busday_offset', See Also -------- - busdaydef: An object for efficiently specifying which are business days. + busdaycalendar: An object for efficiently specifying which are business days. is_busday : Returns a boolean array indicating valid business days. busday_count : Counts how many business days are in a half-open date range. @@ -6140,7 +6142,7 @@ add_newdoc('numpy.core.multiarray', 'busday_offset', add_newdoc('numpy.core.multiarray', 'busday_count', """ - busday_count(begindates, enddates, weekmask='1111100', holidays=[], busdaydef=None, out=None) + busday_count(begindates, enddates, weekmask='1111100', holidays=[], busdaycal=None, out=None) Counts the number of business days between `begindates` and `enddates`, not including the day of `enddates`. @@ -6165,8 +6167,8 @@ add_newdoc('numpy.core.multiarray', 'busday_count', as business days. They may be specified in any order, and NaT (not-a-time) dates are ignored. Internally, this list is normalized into a form suited for fast business day calculations. - busdaydef : busdaydef - A `busdaydef` object which specifies the business days. If this + busdaycal : busdaycalendar + A `busdaycalendar` object which specifies the business days. If this parameter is provided, neither weekmask nor holidays may be provided. out : array of int64 @@ -6181,7 +6183,7 @@ add_newdoc('numpy.core.multiarray', 'busday_count', See Also -------- - busdaydef: An object for efficiently specifying which are business days. + busdaycalendar: An object for efficiently specifying which are business days. is_busday : Returns a boolean array indicating valid business days. busday_offset : Applies an offset counted in business days. diff --git a/numpy/core/SConscript b/numpy/core/SConscript index 37230e50a..0baea3d0c 100644 --- a/numpy/core/SConscript +++ b/numpy/core/SConscript @@ -440,7 +440,7 @@ if ENABLE_SEPARATE_COMPILATION: pjoin('src', 'multiarray', 'arrayobject.c'), pjoin('src', 'multiarray', 'datetime.c'), pjoin('src', 'multiarray', 'datetime_busday.c'), - pjoin('src', 'multiarray', 'datetime_busdaydef.c'), + pjoin('src', 'multiarray', 'datetime_busdaycal.c'), pjoin('src', 'multiarray', 'numpyos.c'), pjoin('src', 'multiarray', 'flagsobject.c'), pjoin('src', 'multiarray', 'descriptor.c'), diff --git a/numpy/core/code_generators/genapi.py b/numpy/core/code_generators/genapi.py index 21e6444e6..844aebff0 100644 --- a/numpy/core/code_generators/genapi.py +++ b/numpy/core/code_generators/genapi.py @@ -45,7 +45,7 @@ API_FILES = [join('multiarray', 'methods.c'), join('multiarray', 'buffer.c'), join('multiarray', 'datetime.c'), join('multiarray', 'datetime_busday.c'), - join('multiarray', 'datetime_busdaydef.c'), + join('multiarray', 'datetime_busdaycal.c'), join('multiarray', 'nditer.c.src'), join('multiarray', 'nditer_pywrap.c'), join('multiarray', 'einsum.c.src'), diff --git a/numpy/core/numerictypes.py b/numpy/core/numerictypes.py index 8d184e47d..f1152cb74 100644 --- a/numpy/core/numerictypes.py +++ b/numpy/core/numerictypes.py @@ -93,11 +93,11 @@ __all__ = ['sctypeDict', 'sctypeNA', 'typeDict', 'typeNA', 'sctypes', 'ScalarType', 'obj2sctype', 'cast', 'nbytes', 'sctype2char', 'maximum_sctype', 'issctype', 'typecodes', 'find_common_type', 'issubdtype', 'datetime_data','datetime_as_string', - 'busday_offset', 'busday_count', 'is_busday', 'busdaydef'] + 'busday_offset', 'busday_count', 'is_busday', 'busdaycalendar'] from numpy.core.multiarray import typeinfo, ndarray, array, \ empty, dtype, datetime_data, datetime_as_string, \ - busday_offset, busday_count, is_busday, busdaydef + busday_offset, busday_count, is_busday, busdaycalendar import types as _types import sys diff --git a/numpy/core/setup.py b/numpy/core/setup.py index 0db4698ed..87e4e4f90 100644 --- a/numpy/core/setup.py +++ b/numpy/core/setup.py @@ -748,7 +748,7 @@ def configuration(parent_package='',top_path=None): join('src', 'multiarray', 'buffer.c'), join('src', 'multiarray', 'datetime.c'), join('src', 'multiarray', 'datetime_busday.c'), - join('src', 'multiarray', 'datetime_busdaydef.c'), + join('src', 'multiarray', 'datetime_busdaycal.c'), join('src', 'multiarray', 'numpyos.c'), join('src', 'multiarray', 'conversion_utils.c'), join('src', 'multiarray', 'flagsobject.c'), diff --git a/numpy/core/src/multiarray/datetime_busday.c b/numpy/core/src/multiarray/datetime_busday.c index 728a7fa16..034e7f6ab 100644 --- a/numpy/core/src/multiarray/datetime_busday.c +++ b/numpy/core/src/multiarray/datetime_busday.c @@ -20,7 +20,7 @@ #include "lowlevel_strided_loops.h" #include "_datetime.h" #include "datetime_busday.h" -#include "datetime_busdaydef.h" +#include "datetime_busdaycal.h" /* Gets the day of the week for a datetime64[D] value */ static int @@ -918,14 +918,14 @@ array_busday_offset(PyObject *NPY_UNUSED(self), PyObject *args, PyObject *kwds) { char *kwlist[] = {"dates", "offsets", "roll", - "weekmask", "holidays", "busdaydef", "out", NULL}; + "weekmask", "holidays", "busdaycal", "out", NULL}; PyObject *dates_in = NULL, *offsets_in = NULL, *out_in = NULL; PyArrayObject *dates = NULL, *offsets = NULL, *out = NULL, *ret; NPY_BUSDAY_ROLL roll = NPY_BUSDAY_RAISE; npy_bool weekmask[7] = {2, 1, 1, 1, 1, 0, 0}; - NpyBusinessDayDef *busdaydef = NULL; + NpyBusDayCalendar *busdaycal = NULL; int i, busdays_in_weekmask; npy_holidayslist holidays = {NULL, NULL}; int allocated_holidays = 1; @@ -937,17 +937,17 @@ array_busday_offset(PyObject *NPY_UNUSED(self), &PyArray_BusDayRollConverter, &roll, &PyArray_WeekMaskConverter, &weekmask[0], &PyArray_HolidaysConverter, &holidays, - &NpyBusinessDayDef_Type, &busdaydef, + &NpyBusDayCalendar_Type, &busdaycal, &out_in)) { goto fail; } - /* Make sure only one of the weekmask/holidays and busdaydef is supplied */ - if (busdaydef != NULL) { + /* Make sure only one of the weekmask/holidays and busdaycal is supplied */ + if (busdaycal != NULL) { if (weekmask[0] != 2 || holidays.begin != NULL) { PyErr_SetString(PyExc_ValueError, "Cannot supply both the weekmask/holidays and the " - "busdaydef parameters to busday_offset()"); + "busdaycal parameters to busday_offset()"); goto fail; } @@ -955,9 +955,9 @@ array_busday_offset(PyObject *NPY_UNUSED(self), allocated_holidays = 0; /* Copy the private normalized weekmask/holidays data */ - holidays = busdaydef->holidays; - busdays_in_weekmask = busdaydef->busdays_in_weekmask; - memcpy(weekmask, busdaydef->weekmask, 7); + holidays = busdaycal->holidays; + busdays_in_weekmask = busdaycal->busdays_in_weekmask; + memcpy(weekmask, busdaycal->weekmask, 7); } else { /* @@ -1048,13 +1048,13 @@ array_busday_count(PyObject *NPY_UNUSED(self), PyObject *args, PyObject *kwds) { char *kwlist[] = {"begindates", "enddates", - "weekmask", "holidays", "busdaydef", "out", NULL}; + "weekmask", "holidays", "busdaycal", "out", NULL}; PyObject *dates_begin_in = NULL, *dates_end_in = NULL, *out_in = NULL; PyArrayObject *dates_begin = NULL, *dates_end = NULL, *out = NULL, *ret; npy_bool weekmask[7] = {2, 1, 1, 1, 1, 0, 0}; - NpyBusinessDayDef *busdaydef = NULL; + NpyBusDayCalendar *busdaycal = NULL; int i, busdays_in_weekmask; npy_holidayslist holidays = {NULL, NULL}; int allocated_holidays = 1; @@ -1065,17 +1065,17 @@ array_busday_count(PyObject *NPY_UNUSED(self), &dates_end_in, &PyArray_WeekMaskConverter, &weekmask[0], &PyArray_HolidaysConverter, &holidays, - &NpyBusinessDayDef_Type, &busdaydef, + &NpyBusDayCalendar_Type, &busdaycal, &out_in)) { goto fail; } - /* Make sure only one of the weekmask/holidays and busdaydef is supplied */ - if (busdaydef != NULL) { + /* Make sure only one of the weekmask/holidays and busdaycal is supplied */ + if (busdaycal != NULL) { if (weekmask[0] != 2 || holidays.begin != NULL) { PyErr_SetString(PyExc_ValueError, "Cannot supply both the weekmask/holidays and the " - "busdaydef parameters to busday_count()"); + "busdaycal parameters to busday_count()"); goto fail; } @@ -1083,9 +1083,9 @@ array_busday_count(PyObject *NPY_UNUSED(self), allocated_holidays = 0; /* Copy the private normalized weekmask/holidays data */ - holidays = busdaydef->holidays; - busdays_in_weekmask = busdaydef->busdays_in_weekmask; - memcpy(weekmask, busdaydef->weekmask, 7); + holidays = busdaycal->holidays; + busdays_in_weekmask = busdaycal->busdays_in_weekmask; + memcpy(weekmask, busdaycal->weekmask, 7); } else { /* @@ -1192,13 +1192,13 @@ array_is_busday(PyObject *NPY_UNUSED(self), PyObject *args, PyObject *kwds) { char *kwlist[] = {"dates", - "weekmask", "holidays", "busdaydef", "out", NULL}; + "weekmask", "holidays", "busdaycal", "out", NULL}; PyObject *dates_in = NULL, *out_in = NULL; PyArrayObject *dates = NULL,*out = NULL, *ret; npy_bool weekmask[7] = {2, 1, 1, 1, 1, 0, 0}; - NpyBusinessDayDef *busdaydef = NULL; + NpyBusDayCalendar *busdaycal = NULL; int i, busdays_in_weekmask; npy_holidayslist holidays = {NULL, NULL}; int allocated_holidays = 1; @@ -1208,17 +1208,17 @@ array_is_busday(PyObject *NPY_UNUSED(self), &dates_in, &PyArray_WeekMaskConverter, &weekmask[0], &PyArray_HolidaysConverter, &holidays, - &NpyBusinessDayDef_Type, &busdaydef, + &NpyBusDayCalendar_Type, &busdaycal, &out_in)) { goto fail; } - /* Make sure only one of the weekmask/holidays and busdaydef is supplied */ - if (busdaydef != NULL) { + /* Make sure only one of the weekmask/holidays and busdaycal is supplied */ + if (busdaycal != NULL) { if (weekmask[0] != 2 || holidays.begin != NULL) { PyErr_SetString(PyExc_ValueError, "Cannot supply both the weekmask/holidays and the " - "busdaydef parameters to is_busday()"); + "busdaycal parameters to is_busday()"); goto fail; } @@ -1226,9 +1226,9 @@ array_is_busday(PyObject *NPY_UNUSED(self), allocated_holidays = 0; /* Copy the private normalized weekmask/holidays data */ - holidays = busdaydef->holidays; - busdays_in_weekmask = busdaydef->busdays_in_weekmask; - memcpy(weekmask, busdaydef->weekmask, 7); + holidays = busdaycal->holidays; + busdays_in_weekmask = busdaycal->busdays_in_weekmask; + memcpy(weekmask, busdaycal->weekmask, 7); } else { /* diff --git a/numpy/core/src/multiarray/datetime_busdaydef.c b/numpy/core/src/multiarray/datetime_busdaycal.c index 396bf82be..3d5bbe1ef 100644 --- a/numpy/core/src/multiarray/datetime_busdaydef.c +++ b/numpy/core/src/multiarray/datetime_busdaycal.c @@ -1,6 +1,6 @@ /* * This file implements an object encapsulating a business day - * definition for accelerating NumPy datetime business day functions. + * calendar object for accelerating NumPy datetime business day functions. * * Written by Mark Wiebe (mwwiebe@gmail.com) * Copyright (c) 2011 by Enthought, Inc. @@ -21,7 +21,7 @@ #include "lowlevel_strided_loops.h" #include "_datetime.h" #include "datetime_busday.h" -#include "datetime_busdaydef.h" +#include "datetime_busdaycal.h" NPY_NO_EXPORT int PyArray_WeekMaskConverter(PyObject *weekmask_in, npy_bool *weekmask) @@ -332,12 +332,12 @@ fail: } static PyObject * -busdaydef_new(PyTypeObject *subtype, +busdaycalendar_new(PyTypeObject *subtype, PyObject *NPY_UNUSED(args), PyObject *NPY_UNUSED(kwds)) { - NpyBusinessDayDef *self; + NpyBusDayCalendar *self; - self = (NpyBusinessDayDef *)subtype->tp_alloc(subtype, 0); + self = (NpyBusDayCalendar *)subtype->tp_alloc(subtype, 0); if (self != NULL) { /* Start with an empty holidays list */ self->holidays.begin = NULL; @@ -358,7 +358,7 @@ busdaydef_new(PyTypeObject *subtype, } static int -busdaydef_init(NpyBusinessDayDef *self, PyObject *args, PyObject *kwds) +busdaycalendar_init(NpyBusDayCalendar *self, PyObject *args, PyObject *kwds) { static char *kwlist[] = {"weekmask", "holidays", NULL}; int i, busdays_in_weekmask; @@ -382,7 +382,7 @@ busdaydef_init(NpyBusinessDayDef *self, PyObject *args, PyObject *kwds) /* Parse the parameters */ if (!PyArg_ParseTupleAndKeywords(args, kwds, - "|O&O&:busdaydef", kwlist, + "|O&O&:busdaycal", kwlist, &PyArray_WeekMaskConverter, &self->weekmask[0], &PyArray_HolidaysConverter, &self->holidays)) { return -1; @@ -400,7 +400,7 @@ busdaydef_init(NpyBusinessDayDef *self, PyObject *args, PyObject *kwds) if (self->busdays_in_weekmask == 0) { PyErr_SetString(PyExc_ValueError, - "Cannot construct a numpy.busdaydef with a weekmask of " + "Cannot construct a numpy.busdaycal with a weekmask of " "all zeros"); return -1; } @@ -409,7 +409,7 @@ busdaydef_init(NpyBusinessDayDef *self, PyObject *args, PyObject *kwds) } static void -busdaydef_dealloc(NpyBusinessDayDef *self) +busdaycalendar_dealloc(NpyBusDayCalendar *self) { /* Clear the holidays */ if (self->holidays.begin != NULL) { @@ -422,7 +422,7 @@ busdaydef_dealloc(NpyBusinessDayDef *self) } static PyObject * -busdaydef_weekmask_get(NpyBusinessDayDef *self) +busdaycalendar_weekmask_get(NpyBusDayCalendar *self) { PyArrayObject *ret; npy_intp size = 7; @@ -440,7 +440,7 @@ busdaydef_weekmask_get(NpyBusinessDayDef *self) } static PyObject * -busdaydef_holidays_get(NpyBusinessDayDef *self) +busdaycalendar_holidays_get(NpyBusDayCalendar *self) { PyArrayObject *ret; PyArray_Descr *date_dtype; @@ -467,29 +467,29 @@ busdaydef_holidays_get(NpyBusinessDayDef *self) return (PyObject *)ret; } -static PyGetSetDef busdaydef_getsets[] = { +static PyGetSetDef busdaycalendar_getsets[] = { {"weekmask", - (getter)busdaydef_weekmask_get, + (getter)busdaycalendar_weekmask_get, NULL, NULL, NULL}, {"holidays", - (getter)busdaydef_holidays_get, + (getter)busdaycalendar_holidays_get, NULL, NULL, NULL}, {NULL, NULL, NULL, NULL, NULL} }; -NPY_NO_EXPORT PyTypeObject NpyBusinessDayDef_Type = { +NPY_NO_EXPORT PyTypeObject NpyBusDayCalendar_Type = { #if defined(NPY_PY3K) PyVarObject_HEAD_INIT(NULL, 0) #else PyObject_HEAD_INIT(NULL) 0, /* ob_size */ #endif - "numpy.busdaydef", /* tp_name */ - sizeof(NpyBusinessDayDef), /* tp_basicsize */ + "numpy.busdaycalendar", /* tp_name */ + sizeof(NpyBusDayCalendar), /* tp_basicsize */ 0, /* tp_itemsize */ /* methods */ - (destructor)busdaydef_dealloc, /* tp_dealloc */ + (destructor)busdaycalendar_dealloc, /* tp_dealloc */ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ @@ -518,15 +518,15 @@ NPY_NO_EXPORT PyTypeObject NpyBusinessDayDef_Type = { 0, /* tp_iternext */ 0, /* tp_methods */ 0, /* tp_members */ - busdaydef_getsets, /* tp_getset */ + busdaycalendar_getsets, /* tp_getset */ 0, /* tp_base */ 0, /* tp_dict */ 0, /* tp_descr_get */ 0, /* tp_descr_set */ 0, /* tp_dictoffset */ - (initproc)busdaydef_init, /* tp_init */ + (initproc)busdaycalendar_init, /* tp_init */ 0, /* tp_alloc */ - busdaydef_new, /* tp_new */ + busdaycalendar_new, /* tp_new */ 0, /* tp_free */ 0, /* tp_is_gc */ 0, /* tp_bases */ diff --git a/numpy/core/src/multiarray/datetime_busdaydef.h b/numpy/core/src/multiarray/datetime_busdaycal.h index b5f100910..8401f38b6 100644 --- a/numpy/core/src/multiarray/datetime_busdaydef.h +++ b/numpy/core/src/multiarray/datetime_busdaycal.h @@ -24,12 +24,9 @@ typedef struct { npy_holidayslist holidays; int busdays_in_weekmask; npy_bool weekmask[7]; -} NpyBusinessDayDef; +} NpyBusDayCalendar; -NPY_NO_EXPORT PyTypeObject NpyBusinessDayDef_Type; - -#define NpyBusinessDayDef_Check(op) PyObject_TypeCheck(op, \ - &NpyBusinessDayDef_Type) +NPY_NO_EXPORT PyTypeObject NpyBusDayCalendar_Type; /* * Converts a Python input into a 7-element weekmask, where 0 means diff --git a/numpy/core/src/multiarray/multiarraymodule.c b/numpy/core/src/multiarray/multiarraymodule.c index 60ee9dbe8..3b136e072 100644 --- a/numpy/core/src/multiarray/multiarraymodule.c +++ b/numpy/core/src/multiarray/multiarraymodule.c @@ -46,7 +46,7 @@ NPY_NO_EXPORT int NPY_NUMUSERTYPES = 0; #include "nditer_pywrap.h" #include "_datetime.h" #include "datetime_busday.h" -#include "datetime_busdaydef.h" +#include "datetime_busdaycal.h" /* Only here for API compatibility */ NPY_NO_EXPORT PyTypeObject PyBigArray_Type; @@ -3922,8 +3922,8 @@ PyMODINIT_FUNC initmultiarray(void) { if (PyType_Ready(&PyArrayFlags_Type) < 0) { return RETVAL; } - NpyBusinessDayDef_Type.tp_new = PyType_GenericNew; - if (PyType_Ready(&NpyBusinessDayDef_Type) < 0) { + NpyBusDayCalendar_Type.tp_new = PyType_GenericNew; + if (PyType_Ready(&NpyBusDayCalendar_Type) < 0) { return RETVAL; } /* FIXME @@ -4005,9 +4005,10 @@ PyMODINIT_FUNC initmultiarray(void) { Py_INCREF(&PyArrayFlags_Type); PyDict_SetItemString(d, "flagsobj", (PyObject *)&PyArrayFlags_Type); - /* Business day definition object */ - Py_INCREF(&NpyBusinessDayDef_Type); - PyDict_SetItemString(d, "busdaydef", (PyObject *)&NpyBusinessDayDef_Type); + /* Business day calendar object */ + Py_INCREF(&NpyBusDayCalendar_Type); + PyDict_SetItemString(d, "busdaycalendar", + (PyObject *)&NpyBusDayCalendar_Type); set_flaginfo(d); diff --git a/numpy/core/src/multiarray/multiarraymodule_onefile.c b/numpy/core/src/multiarray/multiarraymodule_onefile.c index 5f7cf17f3..4459e6b4c 100644 --- a/numpy/core/src/multiarray/multiarraymodule_onefile.c +++ b/numpy/core/src/multiarray/multiarraymodule_onefile.c @@ -12,7 +12,7 @@ #include "datetime.c" #include "datetime_busday.c" -#include "datetime_busdaydef.c" +#include "datetime_busdaycal.c" #include "arraytypes.c" #include "hashdescr.c" diff --git a/numpy/core/tests/test_datetime.py b/numpy/core/tests/test_datetime.py index a3adcb2a6..599ece70d 100644 --- a/numpy/core/tests/test_datetime.py +++ b/numpy/core/tests/test_datetime.py @@ -1206,10 +1206,10 @@ class TestDateTime(TestCase): assert_equal(np.busday_offset('2007-04-07', -11, weekmask='SatSun'), np.datetime64('2007-02-25')) - def test_datetime_busdaydef(self): + def test_datetime_busdaycalendar(self): # Check that it removes NaT, duplicates, and weekends # and sorts the result. - bdd = np.busdaydef( + bdd = np.busdaycalendar( holidays=['NaT', '2011-01-17', '2011-03-06', 'NaT', '2011-12-26','2011-05-30','2011-01-17']) assert_equal(bdd.holidays, @@ -1218,7 +1218,7 @@ class TestDateTime(TestCase): assert_equal(bdd.weekmask, np.array([1,1,1,1,1,0,0], dtype='?')) # All-zeros weekmask should raise - assert_raises(ValueError, np.busdaydef, weekmask=[0,0,0,0,0,0,0]) + assert_raises(ValueError, np.busdaycalendar, weekmask=[0,0,0,0,0,0,0]) def test_datetime_busday_holidays_offset(self): # With exactly one holiday @@ -1290,7 +1290,7 @@ class TestDateTime(TestCase): holidays=['2011-10-10', '2011-11-11', '2011-11-24', '2011-12-25', '2011-05-30', '2011-02-21', '2011-12-26', '2012-01-02'] - bdd = np.busdaydef(weekmask='1111100', holidays=holidays) + bdd = np.busdaycalendar(weekmask='1111100', holidays=holidays) assert_equal( np.busday_offset('2011-10-03', 4, holidays=holidays), np.busday_offset('2011-10-03', 4)) @@ -1322,7 +1322,7 @@ class TestDateTime(TestCase): np.busday_offset('2011-10-03', 61, holidays=holidays), np.busday_offset('2011-10-03', 61 + 5)) assert_equal( - np.busday_offset('2011-10-03', 61, busdaydef=bdd), + np.busday_offset('2011-10-03', 61, busdaycal=bdd), np.busday_offset('2011-10-03', 61 + 5)) # A bigger backward jump across more than one week/holiday assert_equal( @@ -1353,14 +1353,14 @@ class TestDateTime(TestCase): np.busday_offset('2012-01-03', -57, holidays=holidays), np.busday_offset('2012-01-03', -57 - 5)) assert_equal( - np.busday_offset('2012-01-03', -57, busdaydef=bdd), + np.busday_offset('2012-01-03', -57, busdaycal=bdd), np.busday_offset('2012-01-03', -57 - 5)) - # Can't supply both a weekmask/holidays and busdaydef + # Can't supply both a weekmask/holidays and busdaycal assert_raises(ValueError, np.busday_offset, '2012-01-03', -15, - weekmask='1111100', busdaydef=bdd) + weekmask='1111100', busdaycal=bdd) assert_raises(ValueError, np.busday_offset, '2012-01-03', -15, - holidays=holidays, busdaydef=bdd) + holidays=holidays, busdaycal=bdd) # Roll with the holidays assert_equal( @@ -1393,25 +1393,25 @@ class TestDateTime(TestCase): '2011-12-25', '2011-05-30', '2011-02-21', '2011-01-17', '2011-12-26', '2012-01-02', '2011-02-21', '2011-05-30', '2011-07-01', '2011-07-04', '2011-09-05', '2011-10-10'] - bdd = np.busdaydef(weekmask='1111100', holidays=holidays) + bdd = np.busdaycalendar(weekmask='1111100', holidays=holidays) # Validate against busday_offset broadcast against # a range of offsets dates = np.busday_offset('2011-01-01', np.arange(366), - roll='forward', busdaydef=bdd) - assert_equal(np.busday_count('2011-01-01', dates, busdaydef=bdd), + roll='forward', busdaycal=bdd) + assert_equal(np.busday_count('2011-01-01', dates, busdaycal=bdd), np.arange(366)) dates = np.busday_offset('2011-12-31', -np.arange(366), - roll='forward', busdaydef=bdd) - assert_equal(np.busday_count(dates, '2011-12-31', busdaydef=bdd), + roll='forward', busdaycal=bdd) + assert_equal(np.busday_count(dates, '2011-12-31', busdaycal=bdd), np.arange(366)) - # Can't supply both a weekmask/holidays and busdaydef + # Can't supply both a weekmask/holidays and busdaycal assert_raises(ValueError, np.busday_offset, '2012-01-03', '2012-02-03', - weekmask='1111100', busdaydef=bdd) + weekmask='1111100', busdaycal=bdd) assert_raises(ValueError, np.busday_offset, '2012-01-03', '2012-02-03', - holidays=holidays, busdaydef=bdd) + holidays=holidays, busdaycal=bdd) # Number of Mondays in March 2011 assert_equal(np.busday_count('2011-03', '2011-04', weekmask='Mon'), 4) @@ -1422,7 +1422,7 @@ class TestDateTime(TestCase): '2011-12-26', '2012-01-02', '2011-02-21', '2011-05-30', '2011-07-01', '2011-07-04', '2011-09-05', '2011-10-10', 'NaT'] - bdd = np.busdaydef(weekmask='1111100', holidays=holidays) + bdd = np.busdaycalendar(weekmask='1111100', holidays=holidays) # Weekend/weekday tests assert_equal(np.is_busday('2011-01-01'), False) @@ -1430,7 +1430,7 @@ class TestDateTime(TestCase): assert_equal(np.is_busday('2011-01-03'), True) # All the holidays are not business days - assert_equal(np.is_busday(holidays, busdaydef=bdd), + assert_equal(np.is_busday(holidays, busdaycal=bdd), np.zeros(len(holidays), dtype='?')) class TestDateTimeData(TestCase): |