summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCharles Harris <charlesr.harris@gmail.com>2017-10-14 08:26:27 -0600
committerGitHub <noreply@github.com>2017-10-14 08:26:27 -0600
commit56a29d2ca6f9543240a755bf9e4312b1467fe59b (patch)
tree58f76f4b125123fb4931fb9b572cebbfabfde82c
parentd4afa3eba6c9af2a7b85586adbe2801505eaf3ff (diff)
parent3ed10bdd42d2c8393c89114a0cd60a807ddd51b3 (diff)
downloadnumpy-56a29d2ca6f9543240a755bf9e4312b1467fe59b.tar.gz
Merge pull request #9835 from kenogo/master
BENCH: Added missing ufunc benchmarks
-rw-r--r--benchmarks/benchmarks/bench_ufunc.py30
-rw-r--r--doc/release/1.14.0-notes.rst6
-rw-r--r--numpy/core/src/umath/ufunc_type_resolution.c2
-rw-r--r--numpy/core/tests/test_datetime.py2
4 files changed, 22 insertions, 18 deletions
diff --git a/benchmarks/benchmarks/bench_ufunc.py b/benchmarks/benchmarks/bench_ufunc.py
index 8f7d638b5..1d4e70a3a 100644
--- a/benchmarks/benchmarks/bench_ufunc.py
+++ b/benchmarks/benchmarks/bench_ufunc.py
@@ -5,22 +5,20 @@ from .common import Benchmark, get_squares_
import numpy as np
-ufuncs = ['abs', 'absolute', 'add', 'arccos', 'arccosh', 'arcsin',
- 'arcsinh', 'arctan', 'arctan2', 'arctanh', 'bitwise_and',
- 'bitwise_not', 'bitwise_or', 'bitwise_xor', 'cbrt', 'ceil',
- 'conj', 'conjugate', 'copysign', 'cos', 'cosh', 'deg2rad',
- 'degrees', 'divide', 'equal', 'exp', 'exp2', 'expm1',
- 'fabs', 'floor', 'floor_divide', 'fmax', 'fmin', 'fmod',
- 'frexp', 'greater', 'greater_equal', 'hypot', 'invert',
- 'isfinite', 'isinf', 'isnan', 'ldexp', 'left_shift', 'less',
- 'less_equal', 'log', 'log10', 'log1p', 'log2', 'logaddexp',
- 'logaddexp2', 'logical_and', 'logical_not', 'logical_or',
- 'logical_xor', 'maximum', 'minimum', 'mod', 'modf',
- 'multiply', 'negative', 'nextafter', 'not_equal', 'power',
- 'rad2deg', 'radians', 'reciprocal', 'remainder',
- 'right_shift', 'rint', 'sign', 'signbit', 'sin', 'sinh',
- 'spacing', 'sqrt', 'square', 'subtract', 'tan', 'tanh',
- 'true_divide', 'trunc']
+ufuncs = ['abs', 'absolute', 'add', 'arccos', 'arccosh', 'arcsin', 'arcsinh',
+ 'arctan', 'arctan2', 'arctanh', 'bitwise_and', 'bitwise_not',
+ 'bitwise_or', 'bitwise_xor', 'cbrt', 'ceil', 'conj', 'conjugate',
+ 'copysign', 'cos', 'cosh', 'deg2rad', 'degrees', 'divide', 'divmod',
+ 'equal', 'exp', 'exp2', 'expm1', 'fabs', 'float_power', 'floor',
+ 'floor_divide', 'fmax', 'fmin', 'fmod', 'frexp', 'greater',
+ 'greater_equal', 'heaviside', 'hypot', 'invert', 'isfinite', 'isinf',
+ 'isnan', 'isnat', 'ldexp', 'left_shift', 'less', 'less_equal', 'log',
+ 'log10', 'log1p', 'log2', 'logaddexp', 'logaddexp2', 'logical_and',
+ 'logical_not', 'logical_or', 'logical_xor', 'maximum', 'minimum',
+ 'mod', 'modf', 'multiply', 'negative', 'nextafter', 'not_equal',
+ 'positive', 'power', 'rad2deg', 'radians', 'reciprocal', 'remainder',
+ 'right_shift', 'rint', 'sign', 'signbit', 'sin', 'sinh', 'spacing',
+ 'sqrt', 'square', 'subtract', 'tan', 'tanh', 'true_divide', 'trunc']
for name in dir(np):
if isinstance(getattr(np, name, None), np.ufunc) and name not in ufuncs:
diff --git a/doc/release/1.14.0-notes.rst b/doc/release/1.14.0-notes.rst
index 2c99e13e8..66ae50769 100644
--- a/doc/release/1.14.0-notes.rst
+++ b/doc/release/1.14.0-notes.rst
@@ -150,6 +150,12 @@ The previous parameter name ``from`` is a reserved keyword in Python, which made
it difficult to pass the argument by name. This has been fixed by renaming
the parameter to ``from_``.
+``isnat`` raises ``TypeError`` when passed wrong type
+------------------------------------------------------
+The ufunc ``isnat`` used to raise a ``ValueError`` when it was not passed
+variables of type ``datetime`` or ``timedelta``. This has been changed to
+raising a ``TypeError``.
+
C API changes
=============
diff --git a/numpy/core/src/umath/ufunc_type_resolution.c b/numpy/core/src/umath/ufunc_type_resolution.c
index e77b48fc4..1766ba564 100644
--- a/numpy/core/src/umath/ufunc_type_resolution.c
+++ b/numpy/core/src/umath/ufunc_type_resolution.c
@@ -544,7 +544,7 @@ PyUFunc_IsNaTTypeResolver(PyUFuncObject *ufunc,
PyArray_Descr **out_dtypes)
{
if (!PyTypeNum_ISDATETIME(PyArray_DESCR(operands[0])->type_num)) {
- PyErr_SetString(PyExc_ValueError,
+ PyErr_SetString(PyExc_TypeError,
"ufunc 'isnat' is only defined for datetime and timedelta.");
return -1;
}
diff --git a/numpy/core/tests/test_datetime.py b/numpy/core/tests/test_datetime.py
index 10fa9b060..dc84a039c 100644
--- a/numpy/core/tests/test_datetime.py
+++ b/numpy/core/tests/test_datetime.py
@@ -1963,7 +1963,7 @@ class TestDateTime(object):
for t in np.typecodes["All"]:
if t in np.typecodes["Datetime"]:
continue
- assert_raises(ValueError, np.isnat, np.zeros(10, t))
+ assert_raises(TypeError, np.isnat, np.zeros(10, t))
class TestDateTimeData(object):