summaryrefslogtreecommitdiff
path: root/numpy/core/src
diff options
context:
space:
mode:
authorSebastian Berg <sebastian@sipsolutions.net>2021-03-17 20:41:49 -0500
committerSebastian Berg <sebastian@sipsolutions.net>2021-03-17 21:01:52 -0500
commitf473d571f58c78f89979138c8cc79fcf5db05f42 (patch)
tree233cc5690fe4aa406050940228cf1de0a5f25f67 /numpy/core/src
parentf01b7f1c256bc5d1c8ea54d7aa8e9f9beb64c14c (diff)
downloadnumpy-f473d571f58c78f89979138c8cc79fcf5db05f42.tar.gz
TST: Add specific argument parsing tests
Diffstat (limited to 'numpy/core/src')
-rw-r--r--numpy/core/src/multiarray/_multiarray_tests.c.src23
1 files changed, 23 insertions, 0 deletions
diff --git a/numpy/core/src/multiarray/_multiarray_tests.c.src b/numpy/core/src/multiarray/_multiarray_tests.c.src
index 3c8caefce..febcc8512 100644
--- a/numpy/core/src/multiarray/_multiarray_tests.c.src
+++ b/numpy/core/src/multiarray/_multiarray_tests.c.src
@@ -7,6 +7,7 @@
#include "numpy/npy_math.h"
#include "numpy/halffloat.h"
#include "common.h"
+#include "npy_argparse.h"
#include "mem_overlap.h"
#include "npy_extint128.h"
#include "array_method.h"
@@ -19,6 +20,25 @@
#define ARRAY_SIZE(a) (sizeof(a)/sizeof(a[0]))
+
+static PyObject *
+argparse_example_function(PyObject *NPY_UNUSED(mod),
+ PyObject *const *args, Py_ssize_t len_args, PyObject *kwnames)
+{
+ NPY_PREPARE_ARGPARSER;
+ int arg1;
+ PyObject *arg2, *arg3, *arg4;
+ if (npy_parse_arguments("func", args, len_args, kwnames,
+ "", &PyArray_PythonPyIntFromInt, &arg1,
+ "arg2", NULL, &arg2,
+ "|arg3", NULL, &arg3,
+ "$arg3", NULL, &arg4,
+ NULL, NULL, NULL) < 0) {
+ return NULL;
+ }
+ Py_RETURN_NONE;
+}
+
/* test PyArray_IsPythonScalar, before including private py3 compat header */
static PyObject *
IsPythonScalar(PyObject * dummy, PyObject *args)
@@ -2255,6 +2275,9 @@ run_intp_converter(PyObject* NPY_UNUSED(self), PyObject *args)
}
static PyMethodDef Multiarray_TestsMethods[] = {
+ {"argparse_example_function",
+ (PyCFunction)argparse_example_function,
+ METH_KEYWORDS | METH_FASTCALL, NULL},
{"IsPythonScalar",
IsPythonScalar,
METH_VARARGS, NULL},