diff options
author | Mark Wiebe <mwiebe@enthought.com> | 2011-06-01 14:06:13 -0500 |
---|---|---|
committer | Mark Wiebe <mwiebe@enthought.com> | 2011-06-01 14:06:13 -0500 |
commit | 3dd1018f1d0a51632d91127276631b32e3fed1e8 (patch) | |
tree | 74c77511529b693e6752646a0a059a66a1d64e3f | |
parent | 33babc9304569a7773df31bf5dd265be35ece449 (diff) | |
download | numpy-3dd1018f1d0a51632d91127276631b32e3fed1e8.tar.gz |
ENH: datetime: Remove logical operations from timedelta
I think the right way to handle the logical operations is to
reduce them to have just a single loop with all booleans, then
use casting to get the inputs to those types. This change requires
adding custom type resolution to the reduction ufunc methods as well,
which is beyond the scope of datetime.
-rw-r--r-- | numpy/core/src/umath/loops.c.src | 36 | ||||
-rw-r--r-- | numpy/core/src/umath/loops.h | 65 | ||||
-rw-r--r-- | numpy/core/src/umath/loops.h.src | 16 |
3 files changed, 24 insertions, 93 deletions
diff --git a/numpy/core/src/umath/loops.c.src b/numpy/core/src/umath/loops.c.src index 294eb7f47..31345ff45 100644 --- a/numpy/core/src/umath/loops.c.src +++ b/numpy/core/src/umath/loops.c.src @@ -978,42 +978,6 @@ TIMEDELTA_sign(char **args, intp *dimensions, intp *steps, void *NPY_UNUSED(func } } -NPY_NO_EXPORT void -TIMEDELTA_logical_not(char **args, intp *dimensions, intp *steps, void *NPY_UNUSED(func)) -{ - UNARY_LOOP { - const npy_timedelta in1 = *(npy_timedelta *)ip1; - *((Bool *)op1) = !in1; - } -} - -NPY_NO_EXPORT void -TIMEDELTA_logical_xor(char **args, intp *dimensions, intp *steps, void *NPY_UNUSED(func)) -{ - BINARY_LOOP { - const npy_timedelta in1 = *(npy_timedelta *)ip1; - const npy_timedelta in2 = *(npy_timedelta *)ip2; - *((Bool *)op1)= (in1 && !in2) || (!in1 && in2); - } -} - - -/**begin repeat - * #kind = logical_and, logical_or# - * #OP = &&, ||# - */ -NPY_NO_EXPORT void -TIMEDELTA_@kind@(char **args, intp *dimensions, intp *steps, void *NPY_UNUSED(func)) -{ - BINARY_LOOP { - const npy_timedelta in1 = *(npy_timedelta *)ip1; - const npy_timedelta in2 = *(npy_timedelta *)ip2; - *((Bool *)op1) = in1 @OP@ in2; - } -} -/**end repeat**/ - - /**begin repeat * #type = datetime, timedelta# * #TYPE = DATETIME, TIMEDELTA# diff --git a/numpy/core/src/umath/loops.h b/numpy/core/src/umath/loops.h index a68b48fcd..2a827e168 100644 --- a/numpy/core/src/umath/loops.h +++ b/numpy/core/src/umath/loops.h @@ -2544,98 +2544,81 @@ TIMEDELTA_absolute(char **args, intp *dimensions, intp *steps, void *NPY_UNUSED( NPY_NO_EXPORT void TIMEDELTA_sign(char **args, intp *dimensions, intp *steps, void *NPY_UNUSED(func)); -NPY_NO_EXPORT void -TIMEDELTA_logical_not(char **args, intp *dimensions, intp *steps, void *NPY_UNUSED(func)); - -NPY_NO_EXPORT void -TIMEDELTA_logical_xor(char **args, intp *dimensions, intp *steps, void *NPY_UNUSED(func)); - - -#line 439 -NPY_NO_EXPORT void -TIMEDELTA_logical_and(char **args, intp *dimensions, intp *steps, void *NPY_UNUSED(func)); - -#line 439 -NPY_NO_EXPORT void -TIMEDELTA_logical_or(char **args, intp *dimensions, intp *steps, void *NPY_UNUSED(func)); - - - -#line 448 +#line 432 NPY_NO_EXPORT void DATETIME_ones_like(char **args, intp *dimensions, intp *steps, void *NPY_UNUSED(data)); -#line 456 +#line 440 NPY_NO_EXPORT void DATETIME_equal(char **args, intp *dimensions, intp *steps, void *NPY_UNUSED(func)); -#line 456 +#line 440 NPY_NO_EXPORT void DATETIME_not_equal(char **args, intp *dimensions, intp *steps, void *NPY_UNUSED(func)); -#line 456 +#line 440 NPY_NO_EXPORT void DATETIME_greater(char **args, intp *dimensions, intp *steps, void *NPY_UNUSED(func)); -#line 456 +#line 440 NPY_NO_EXPORT void DATETIME_greater_equal(char **args, intp *dimensions, intp *steps, void *NPY_UNUSED(func)); -#line 456 +#line 440 NPY_NO_EXPORT void DATETIME_less(char **args, intp *dimensions, intp *steps, void *NPY_UNUSED(func)); -#line 456 +#line 440 NPY_NO_EXPORT void DATETIME_less_equal(char **args, intp *dimensions, intp *steps, void *NPY_UNUSED(func)); -#line 464 +#line 448 NPY_NO_EXPORT void DATETIME_maximum(char **args, intp *dimensions, intp *steps, void *NPY_UNUSED(func)); -#line 464 +#line 448 NPY_NO_EXPORT void DATETIME_minimum(char **args, intp *dimensions, intp *steps, void *NPY_UNUSED(func)); -#line 448 +#line 432 NPY_NO_EXPORT void TIMEDELTA_ones_like(char **args, intp *dimensions, intp *steps, void *NPY_UNUSED(data)); -#line 456 +#line 440 NPY_NO_EXPORT void TIMEDELTA_equal(char **args, intp *dimensions, intp *steps, void *NPY_UNUSED(func)); -#line 456 +#line 440 NPY_NO_EXPORT void TIMEDELTA_not_equal(char **args, intp *dimensions, intp *steps, void *NPY_UNUSED(func)); -#line 456 +#line 440 NPY_NO_EXPORT void TIMEDELTA_greater(char **args, intp *dimensions, intp *steps, void *NPY_UNUSED(func)); -#line 456 +#line 440 NPY_NO_EXPORT void TIMEDELTA_greater_equal(char **args, intp *dimensions, intp *steps, void *NPY_UNUSED(func)); -#line 456 +#line 440 NPY_NO_EXPORT void TIMEDELTA_less(char **args, intp *dimensions, intp *steps, void *NPY_UNUSED(func)); -#line 456 +#line 440 NPY_NO_EXPORT void TIMEDELTA_less_equal(char **args, intp *dimensions, intp *steps, void *NPY_UNUSED(func)); -#line 464 +#line 448 NPY_NO_EXPORT void TIMEDELTA_maximum(char **args, intp *dimensions, intp *steps, void *NPY_UNUSED(func)); -#line 464 +#line 448 NPY_NO_EXPORT void TIMEDELTA_minimum(char **args, intp *dimensions, intp *steps, void *NPY_UNUSED(func)); @@ -2695,27 +2678,27 @@ TIMEDELTA_md_m_divide(char **args, intp *dimensions, intp *steps, void *NPY_UNUS ***************************************************************************** */ -#line 527 +#line 511 NPY_NO_EXPORT void OBJECT_equal(char **args, intp *dimensions, intp *steps, void *NPY_UNUSED(func)); -#line 527 +#line 511 NPY_NO_EXPORT void OBJECT_not_equal(char **args, intp *dimensions, intp *steps, void *NPY_UNUSED(func)); -#line 527 +#line 511 NPY_NO_EXPORT void OBJECT_greater(char **args, intp *dimensions, intp *steps, void *NPY_UNUSED(func)); -#line 527 +#line 511 NPY_NO_EXPORT void OBJECT_greater_equal(char **args, intp *dimensions, intp *steps, void *NPY_UNUSED(func)); -#line 527 +#line 511 NPY_NO_EXPORT void OBJECT_less(char **args, intp *dimensions, intp *steps, void *NPY_UNUSED(func)); -#line 527 +#line 511 NPY_NO_EXPORT void OBJECT_less_equal(char **args, intp *dimensions, intp *steps, void *NPY_UNUSED(func)); diff --git a/numpy/core/src/umath/loops.h.src b/numpy/core/src/umath/loops.h.src index 40e56d75d..bf41e4187 100644 --- a/numpy/core/src/umath/loops.h.src +++ b/numpy/core/src/umath/loops.h.src @@ -425,22 +425,6 @@ TIMEDELTA_absolute(char **args, intp *dimensions, intp *steps, void *NPY_UNUSED( NPY_NO_EXPORT void TIMEDELTA_sign(char **args, intp *dimensions, intp *steps, void *NPY_UNUSED(func)); -NPY_NO_EXPORT void -TIMEDELTA_logical_not(char **args, intp *dimensions, intp *steps, void *NPY_UNUSED(func)); - -NPY_NO_EXPORT void -TIMEDELTA_logical_xor(char **args, intp *dimensions, intp *steps, void *NPY_UNUSED(func)); - - -/**begin repeat - * #kind = logical_and, logical_or# - * #OP = &&, ||# - */ -NPY_NO_EXPORT void -TIMEDELTA_@kind@(char **args, intp *dimensions, intp *steps, void *NPY_UNUSED(func)); -/**end repeat**/ - - /**begin repeat * #type = datetime, timedelta# * #TYPE = DATETIME, TIMEDELTA# |