summaryrefslogtreecommitdiff
path: root/numpy
diff options
context:
space:
mode:
authorkritisingh1 <kritisingh1.ks@gmail.com>2019-07-26 02:11:20 +0530
committerkritisingh1 <kritisingh1.ks@gmail.com>2019-08-24 13:46:42 +0530
commit1885ec72990aa38da2eb8259331d9976e03e4495 (patch)
tree4da75acaeff47e96c1cb971cabaea9c4c73931f3 /numpy
parentf7f87596aee84daba42d90736af2eeb740eb14f7 (diff)
downloadnumpy-1885ec72990aa38da2eb8259331d9976e03e4495.tar.gz
TST: Add tests for deprecated C functions (PyArray_As1D, PyArray_As1D)
Diffstat (limited to 'numpy')
-rw-r--r--numpy/core/src/multiarray/_multiarray_tests.c.src35
-rw-r--r--numpy/core/tests/test_deprecations.py12
2 files changed, 47 insertions, 0 deletions
diff --git a/numpy/core/src/multiarray/_multiarray_tests.c.src b/numpy/core/src/multiarray/_multiarray_tests.c.src
index 1365e87bb..e361826f9 100644
--- a/numpy/core/src/multiarray/_multiarray_tests.c.src
+++ b/numpy/core/src/multiarray/_multiarray_tests.c.src
@@ -656,6 +656,35 @@ npy_updateifcopy_deprecation(PyObject* NPY_UNUSED(self), PyObject* args)
Py_RETURN_NONE;
}
+/* used to test PyArray_As1D usage emits not implemented error */
+static PyObject*
+npy_pyarrayas1d_deprecation(PyObject* NPY_UNUSED(self), PyObject* NPY_UNUSED(args))
+{
+ PyObject **result = Py_BuildValue("i", 42);
+ int dim = 4;
+ double arg[2] = {1, 2};
+ int temp = PyArray_As1D(result, (char **)&arg, &dim, NPY_DOUBLE);
+ if (temp < 0) {
+ return NULL;
+ }
+ return *result;
+}
+
+/* used to test PyArray_As2D usage emits not implemented error */
+static PyObject*
+npy_pyarrayas2d_deprecation(PyObject* NPY_UNUSED(self), PyObject* NPY_UNUSED(args))
+{
+ PyObject **result = Py_BuildValue("i", 42);
+ int dim1 = 4;
+ int dim2 = 6;
+ double arg[2][2] = {{1, 2}, {3, 4}};
+ int temp = PyArray_As2D(result, (char ***)&arg, &dim1, &dim2, NPY_DOUBLE);
+ if (temp < 0) {
+ return NULL;
+ }
+ return *result;
+}
+
/* used to create array with WRITEBACKIFCOPY flag */
static PyObject*
npy_create_writebackifcopy(PyObject* NPY_UNUSED(self), PyObject* args)
@@ -1939,6 +1968,12 @@ static PyMethodDef Multiarray_TestsMethods[] = {
{"npy_updateifcopy_deprecation",
npy_updateifcopy_deprecation,
METH_O, NULL},
+ {"npy_pyarrayas1d_deprecation",
+ npy_pyarrayas1d_deprecation,
+ METH_NOARGS, NULL},
+ {"npy_pyarrayas2d_deprecation",
+ npy_pyarrayas2d_deprecation,
+ METH_NOARGS, NULL},
{"npy_create_writebackifcopy",
npy_create_writebackifcopy,
METH_O, NULL},
diff --git a/numpy/core/tests/test_deprecations.py b/numpy/core/tests/test_deprecations.py
index e8aa0c70b..f02b2cdc9 100644
--- a/numpy/core/tests/test_deprecations.py
+++ b/numpy/core/tests/test_deprecations.py
@@ -442,6 +442,18 @@ class TestNPY_CHAR(_DeprecationTestCase):
assert_(npy_char_deprecation() == 'S1')
+class TestPyArray_AS1D(_DeprecationTestCase):
+ def test_npy_pyarrayas1d_deprecation(self):
+ from numpy.core._multiarray_tests import npy_pyarrayas1d_deprecation
+ assert_raises(NotImplementedError, npy_pyarrayas1d_deprecation)
+
+
+class TestPyArray_AS2D(_DeprecationTestCase):
+ def test_npy_pyarrayas2d_deprecation(self):
+ from numpy.core._multiarray_tests import npy_pyarrayas2d_deprecation
+ assert_raises(NotImplementedError, npy_pyarrayas2d_deprecation)
+
+
class Test_UPDATEIFCOPY(_DeprecationTestCase):
"""
v1.14 deprecates creating an array with the UPDATEIFCOPY flag, use