|
| 1 | +#define NPY_NO_DEPRECATED_API NPY_API_VERSION |
| 2 | + |
| 3 | +#include "Python.h" |
| 4 | + |
| 5 | +#include "npy_pycompat.h" |
| 6 | +#include "npy_config.h" |
| 7 | +#include "numpy/npy_math.h" |
| 8 | + |
| 9 | +#define CACOS 1 |
| 10 | +#define CASIN 1 |
| 11 | +#define CATAN 1 |
| 12 | +#define CACOSH 1 |
| 13 | +#define CASINH 1 |
| 14 | +#define CATANH 1 |
| 15 | +#define CCOS 1 |
| 16 | +#define CSIN 1 |
| 17 | +#define CTAN 1 |
| 18 | +#define CCOSH 1 |
| 19 | +#define CSINH 1 |
| 20 | +#define CTANH 1 |
| 21 | +#define CEXP 1 |
| 22 | +#define CLOG 1 |
| 23 | +#define CPOW 1 |
| 24 | +#define CSQRT 1 |
| 25 | +#define HAVE_NUMPY 1 |
| 26 | + |
| 27 | +#define FLOAT 1 |
| 28 | +#include "../../test_c99complex.c" |
| 29 | +#undef FLOAT |
| 30 | + |
| 31 | +#define DOUBLE 1 |
| 32 | +#include "../../test_c99complex.c" |
| 33 | +#undef DOUBLE |
| 34 | + |
| 35 | +#define LONGDOUBLE 1 |
| 36 | +#include "../../test_c99complex.c" |
| 37 | +#undef LONGDOUBLE |
| 38 | + |
| 39 | +#define TESTFUNC_INT(func, suffix) \ |
| 40 | + static PyObject * CONCAT3(_test_, func, suffix)(PyObject *NPY_UNUSED(self), PyObject *NPY_UNUSED(args)) \ |
| 41 | + { \ |
| 42 | + PyObject *errs; \ |
| 43 | + errs = CONCAT3(test_, func, suffix)(); \ |
| 44 | + if (errs == NULL) { \ |
| 45 | + return errs; \ |
| 46 | + } \ |
| 47 | + if (PySequence_Size(errs) == 0) { \ |
| 48 | + Py_DECREF(errs); \ |
| 49 | + Py_INCREF(Py_None); \ |
| 50 | + return Py_None; \ |
| 51 | + } \ |
| 52 | + else { \ |
| 53 | + PyErr_SetObject(PyExc_AssertionError, errs); \ |
| 54 | + return NULL; \ |
| 55 | + } \ |
| 56 | + } |
| 57 | + |
| 58 | +#define TESTFUNC(func) \ |
| 59 | + TESTFUNC_INT(func, f) \ |
| 60 | + TESTFUNC_INT(func, ) \ |
| 61 | + TESTFUNC_INT(func, l) |
| 62 | + |
| 63 | +#define TESTMETHODDEF_INT(func, suffix) \ |
| 64 | + {STRINGIZE(CONCAT3(test_, func, suffix)), CONCAT3(_test_, func, suffix), METH_VARARGS, ""} |
| 65 | + |
| 66 | +#define TESTMETHODDEF(func) \ |
| 67 | + TESTMETHODDEF_INT(func, f), \ |
| 68 | + TESTMETHODDEF_INT(func, ), \ |
| 69 | + TESTMETHODDEF_INT(func, l) |
| 70 | + |
| 71 | +TESTFUNC(cacos) |
| 72 | +TESTFUNC(casin) |
| 73 | +TESTFUNC(catan) |
| 74 | +TESTFUNC(cacosh) |
| 75 | +TESTFUNC(casinh) |
| 76 | +TESTFUNC(catanh) |
| 77 | +TESTFUNC(ccos) |
| 78 | +TESTFUNC(csin) |
| 79 | +TESTFUNC(ctan) |
| 80 | +TESTFUNC(ccosh) |
| 81 | +TESTFUNC(csinh) |
| 82 | +TESTFUNC(ctanh) |
| 83 | +TESTFUNC(cexp) |
| 84 | +TESTFUNC(clog) |
| 85 | +TESTFUNC(cpow) |
| 86 | +TESTFUNC(csqrt) |
| 87 | + |
| 88 | +static PyMethodDef methods[] = { |
| 89 | + TESTMETHODDEF(cacos), |
| 90 | + TESTMETHODDEF(casin), |
| 91 | + TESTMETHODDEF(catan), |
| 92 | + TESTMETHODDEF(cacosh), |
| 93 | + TESTMETHODDEF(casinh), |
| 94 | + TESTMETHODDEF(catanh), |
| 95 | + TESTMETHODDEF(ccos), |
| 96 | + TESTMETHODDEF(csin), |
| 97 | + TESTMETHODDEF(ctan), |
| 98 | + TESTMETHODDEF(ccosh), |
| 99 | + TESTMETHODDEF(csinh), |
| 100 | + TESTMETHODDEF(ctanh), |
| 101 | + TESTMETHODDEF(cexp), |
| 102 | + TESTMETHODDEF(clog), |
| 103 | + TESTMETHODDEF(cpow), |
| 104 | + TESTMETHODDEF(csqrt), |
| 105 | + {NULL, NULL, 0, NULL} |
| 106 | +}; |
| 107 | + |
| 108 | +#if defined(NPY_PY3K) |
| 109 | +static struct PyModuleDef moduledef = { |
| 110 | + PyModuleDef_HEAD_INIT, |
| 111 | + "npymath_tests", |
| 112 | + NULL, |
| 113 | + -1, |
| 114 | + methods, |
| 115 | + NULL, |
| 116 | + NULL, |
| 117 | + NULL, |
| 118 | + NULL |
| 119 | +}; |
| 120 | +#endif |
| 121 | + |
| 122 | +#if defined(NPY_PY3K) |
| 123 | +PyMODINIT_FUNC PyInit_npymath_tests(void) |
| 124 | +#else |
| 125 | +PyMODINIT_FUNC |
| 126 | +initnpymath_tests(void) |
| 127 | +#endif |
| 128 | +{ |
| 129 | +#if defined(NPY_PY3K) |
| 130 | + return PyModule_Create(&moduledef); |
| 131 | +#else |
| 132 | + Py_InitModule("npymath_tests", methods); |
| 133 | +#endif |
| 134 | +} |
| 135 | + |
0 commit comments