summaryrefslogtreecommitdiff
path: root/numpy/core/src
diff options
context:
space:
mode:
authorCharles Harris <charlesr.harris@gmail.com>2019-04-22 19:04:52 -0600
committerGitHub <noreply@github.com>2019-04-22 19:04:52 -0600
commit6473fa20407ccd7581ac90cb3ef5b921a4a75cd7 (patch)
tree57a44c55676a82ee9d689e047751c40b009bde89 /numpy/core/src
parent2b59dcb273f00e7be13cdc32c5f396a55781c2f4 (diff)
parent55c7ed2c6822b5a5b30db7472c863dc1fa0c338f (diff)
downloadnumpy-6473fa20407ccd7581ac90cb3ef5b921a4a75cd7.tar.gz
Merge pull request #13371 from eric-wieser/__floor__-and-__ceil__
BUG/ENH: Make floor, ceil, and trunc call the matching special methods
Diffstat (limited to 'numpy/core/src')
-rw-r--r--numpy/core/src/umath/funcs.inc.src33
1 files changed, 33 insertions, 0 deletions
diff --git a/numpy/core/src/umath/funcs.inc.src b/numpy/core/src/umath/funcs.inc.src
index da2ab07f8..2acae3c37 100644
--- a/numpy/core/src/umath/funcs.inc.src
+++ b/numpy/core/src/umath/funcs.inc.src
@@ -160,6 +160,39 @@ npy_ObjectLogicalNot(PyObject *i1)
}
static PyObject *
+npy_ObjectFloor(PyObject *obj) {
+ PyObject *math_floor_func = NULL;
+
+ npy_cache_import("math", "floor", &math_floor_func);
+ if (math_floor_func == NULL) {
+ return NULL;
+ }
+ return PyObject_CallFunction(math_floor_func, "O", obj);
+}
+
+static PyObject *
+npy_ObjectCeil(PyObject *obj) {
+ PyObject *math_ceil_func = NULL;
+
+ npy_cache_import("math", "ceil", &math_ceil_func);
+ if (math_ceil_func == NULL) {
+ return NULL;
+ }
+ return PyObject_CallFunction(math_ceil_func, "O", obj);
+}
+
+static PyObject *
+npy_ObjectTrunc(PyObject *obj) {
+ PyObject *math_trunc_func = NULL;
+
+ npy_cache_import("math", "trunc", &math_trunc_func);
+ if (math_trunc_func == NULL) {
+ return NULL;
+ }
+ return PyObject_CallFunction(math_trunc_func, "O", obj);
+}
+
+static PyObject *
npy_ObjectGCD(PyObject *i1, PyObject *i2)
{
PyObject *gcd = NULL;