Skip to content

Commit

Permalink
DEP: Emit FutureWarning for NAT comparisons.
Browse files Browse the repository at this point in the history
In Numpy 1.13 the plan is for NAT comparisons to behave like NaN
comparisons, e.g., False except for 'NAT != NAT', which will be
True. See the discussion at numpygh-7019 for details.
  • Loading branch information
charris committed Jan 19, 2016
1 parent aa82467 commit ae85a33
Showing 1 changed file with 41 additions and 3 deletions.
44 changes: 41 additions & 3 deletions numpy/core/src/umath/loops.c.src
Original file line number Diff line number Diff line change
Expand Up @@ -1117,20 +1117,58 @@ NPY_NO_EXPORT void
}

/**begin repeat1
* #kind = equal, not_equal, greater, greater_equal, less, less_equal#
* #OP = ==, !=, >, >=, <, <=#
* #kind = equal, greater, greater_equal, less, less_equal#
* #OP = ==, >, >=, <, <=#
*/
NPY_NO_EXPORT void
@TYPE@_@kind@(char **args, npy_intp *dimensions, npy_intp *steps, void *NPY_UNUSED(func))
{
BINARY_LOOP {
const @type@ in1 = *(@type@ *)ip1;
const @type@ in2 = *(@type@ *)ip2;
*((npy_bool *)op1) = in1 @OP@ in2;
const npy_bool res = in1 @OP@ in2;
*((npy_bool *)op1) = res;

if ((in1 == NPY_DATETIME_NAT || in2 == NPY_DATETIME_NAT) && res) {
NPY_ALLOW_C_API_DEF
NPY_ALLOW_C_API;
/* 2016-01-18, 1.11 */
if (DEPRECATE_FUTUREWARNING(
"In the future, 'NAT @OP@ x' and 'x @OP@ NAT' "
"will always be False.") < 0) {
NPY_DISABLE_C_API;
return;
}
NPY_DISABLE_C_API;
}
}
}
/**end repeat1**/

NPY_NO_EXPORT void
@TYPE@_not_equal(char **args, npy_intp *dimensions, npy_intp *steps, void *NPY_UNUSED(func))
{
BINARY_LOOP {
const @type@ in1 = *(@type@ *)ip1;
const @type@ in2 = *(@type@ *)ip2;
*((npy_bool *)op1) = in1 != in2;

if (in1 == NPY_DATETIME_NAT && in1 == NPY_DATETIME_NAT) {
NPY_ALLOW_C_API_DEF
NPY_ALLOW_C_API;
/* 2016-01-18, 1.11 */
if (DEPRECATE_FUTUREWARNING(
"In the future, NAT != NAT will be True "
"rather than False.") < 0) {
NPY_DISABLE_C_API;
return;
}
NPY_DISABLE_C_API;
}
}
}


/**begin repeat1
* #kind = maximum, minimum#
* #OP = >, <#
Expand Down

0 comments on commit ae85a33

Please sign in to comment.