diff options
| author | Travis Oliphant <oliphant@enthought.com> | 2006-03-14 07:53:59 +0000 |
|---|---|---|
| committer | Travis Oliphant <oliphant@enthought.com> | 2006-03-14 07:53:59 +0000 |
| commit | 7afda6a7aa249f3bfe490e62f61480d9e5e9c941 (patch) | |
| tree | c7ef3a6e3bca2148ffd06bf4824a897bd58c559d /numpy | |
| parent | 22335be3938621d9a4ed0ca0ac8ec5a8fc5a1da3 (diff) | |
| download | numpy-7afda6a7aa249f3bfe490e62f61480d9e5e9c941.tar.gz | |
Add rest of the examples for pyrex and swig
Diffstat (limited to 'numpy')
| -rw-r--r-- | numpy/doc/pyrex/MANIFEST | 2 | ||||
| -rw-r--r-- | numpy/doc/pyrex/Makefile | 9 | ||||
| -rw-r--r-- | numpy/doc/pyrex/c_python.pxd | 20 | ||||
| -rw-r--r-- | numpy/doc/pyrex/notes | 3 | ||||
| -rw-r--r-- | numpy/doc/pyrex/numpyx.c | 1038 | ||||
| -rw-r--r-- | numpy/doc/pyrex/numpyx.pyx | 97 | ||||
| -rwxr-xr-x | numpy/doc/pyrex/run_test.py | 3 | ||||
| -rw-r--r-- | numpy/doc/pyrex/setup.py | 42 | ||||
| -rw-r--r-- | numpy/doc/swig/HelperFunctions.txt | 104 | ||||
| -rw-r--r-- | numpy/doc/swig/Makefile | 14 | ||||
| -rw-r--r-- | numpy/doc/swig/README | 122 | ||||
| -rw-r--r-- | numpy/doc/swig/Series.i | 31 | ||||
| -rw-r--r-- | numpy/doc/swig/series.cxx | 145 | ||||
| -rw-r--r-- | numpy/doc/swig/series.h | 40 | ||||
| -rwxr-xr-x | numpy/doc/swig/setup.py | 24 | ||||
| -rwxr-xr-x | numpy/doc/swig/testSeries.py | 186 |
16 files changed, 1880 insertions, 0 deletions
diff --git a/numpy/doc/pyrex/MANIFEST b/numpy/doc/pyrex/MANIFEST new file mode 100644 index 000000000..feb3ec22a --- /dev/null +++ b/numpy/doc/pyrex/MANIFEST @@ -0,0 +1,2 @@ +numpyx.pyx +setup.py diff --git a/numpy/doc/pyrex/Makefile b/numpy/doc/pyrex/Makefile new file mode 100644 index 000000000..b5905e7be --- /dev/null +++ b/numpy/doc/pyrex/Makefile @@ -0,0 +1,9 @@ +all: + python setup.py build_ext --inplace + +test: all + python run_test.py + +.PHONY: clean +clean: + rm -rf *~ *.so *.c *.o build diff --git a/numpy/doc/pyrex/c_python.pxd b/numpy/doc/pyrex/c_python.pxd new file mode 100644 index 000000000..53f6d9b19 --- /dev/null +++ b/numpy/doc/pyrex/c_python.pxd @@ -0,0 +1,20 @@ +# -*- Mode: Python -*- Not really, but close enough + +# Expose as much of the Python C API as we need here + +cdef extern from "stdlib.h": + ctypedef int size_t + +cdef extern from "Python.h": + ctypedef int Py_intptr_t + void* PyMem_Malloc(size_t) + void* PyMem_Realloc(void *p, size_t n) + void PyMem_Free(void *p) + char* PyString_AsString(object string) + object PyString_FromString(char *v) + object PyString_InternFromString(char *v) + int PyErr_CheckSignals() + object PyFloat_FromDouble(double v) + void Py_XINCREF(object o) + void Py_XDECREF(object o) + void Py_CLEAR(object o) # use instead of decref diff --git a/numpy/doc/pyrex/notes b/numpy/doc/pyrex/notes new file mode 100644 index 000000000..301581cee --- /dev/null +++ b/numpy/doc/pyrex/notes @@ -0,0 +1,3 @@ +- cimport with a .pxd file vs 'include foo.pxi'? + +- the need to repeat: pyrex does NOT parse C headers.
\ No newline at end of file diff --git a/numpy/doc/pyrex/numpyx.c b/numpy/doc/pyrex/numpyx.c new file mode 100644 index 000000000..0e2658242 --- /dev/null +++ b/numpy/doc/pyrex/numpyx.c @@ -0,0 +1,1038 @@ +/* Generated by Pyrex 0.9.2.1 on Sun Mar 12 19:19:16 2006 */ + +#include "Python.h" +#include "structmember.h" +#ifndef PY_LONG_LONG + #define PY_LONG_LONG LONG_LONG +#endif +#include "stdlib.h" +#include "numpy/arrayobject.h" + + +typedef struct {PyObject **p; char *s;} __Pyx_InternTabEntry; /*proto*/ +typedef struct {PyObject **p; char *s; long n;} __Pyx_StringTabEntry; /*proto*/ +static PyObject *__Pyx_UnpackItem(PyObject *, int); /*proto*/ +static int __Pyx_EndUnpack(PyObject *, int); /*proto*/ +static int __Pyx_PrintItem(PyObject *); /*proto*/ +static int __Pyx_PrintNewline(void); /*proto*/ +static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb); /*proto*/ +static void __Pyx_ReRaise(void); /*proto*/ +static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list); /*proto*/ +static PyObject *__Pyx_GetExcValue(void); /*proto*/ +static int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed, char *name); /*proto*/ +static int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type); /*proto*/ +static int __Pyx_GetStarArgs(PyObject **args, PyObject **kwds, char *kwd_list[], int nargs, PyObject **args2, PyObject **kwds2); /*proto*/ +static void __Pyx_WriteUnraisable(char *name); /*proto*/ +static void __Pyx_AddTraceback(char *funcname); /*proto*/ +static PyTypeObject *__Pyx_ImportType(char *module_name, char *class_name, long size); /*proto*/ +static int __Pyx_SetVtable(PyObject *dict, void *vtable); /*proto*/ +static int __Pyx_GetVtable(PyObject *dict, void **vtabptr); /*proto*/ +static PyObject *__Pyx_CreateClass(PyObject *bases, PyObject *dict, PyObject *name, char *modname); /*proto*/ +static int __Pyx_InternStrings(__Pyx_InternTabEntry *t); /*proto*/ +static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); /*proto*/ +static PyObject *__Pyx_GetName(PyObject *dict, PyObject *name); /*proto*/ + +static PyObject *__pyx_m; +static PyObject *__pyx_b; +static int __pyx_lineno; +static char *__pyx_filename; +staticforward char **__pyx_f; + +/* Declarations from c_python */ + + +/* Declarations from c_numpy */ + +static PyTypeObject *__pyx_ptype_7c_numpy_dtype = 0; +static PyTypeObject *__pyx_ptype_7c_numpy_ndarray = 0; + +/* Declarations from numpyx */ + +static PyObject *(__pyx_f_6numpyx_print_elements(char (*),int (*),int (*),int ,int ,PyObject *)); /*proto*/ + +/* Implementation of numpyx */ + + +static PyObject *__pyx_n_c_python; +static PyObject *__pyx_n_c_numpy; +static PyObject *__pyx_n_numpy; +static PyObject *__pyx_n_print_array_info; +static PyObject *__pyx_n_test_methods; +static PyObject *__pyx_n_test; + +static PyObject *__pyx_n_dtype; + +static PyObject *__pyx_k2p; +static PyObject *__pyx_k3p; +static PyObject *__pyx_k4p; +static PyObject *__pyx_k5p; +static PyObject *__pyx_k6p; +static PyObject *__pyx_k7p; +static PyObject *__pyx_k8p; +static PyObject *__pyx_k9p; + +char (__pyx_k2[]) = "-="; +char (__pyx_k3[]) = "printing array info for ndarray at 0x%0lx"; +char (__pyx_k4[]) = "print number of dimensions:"; +char (__pyx_k5[]) = "address of strides: 0x%0lx"; +char (__pyx_k6[]) = "strides:"; +char (__pyx_k7[]) = " stride %d:"; +char (__pyx_k8[]) = "memory dump:"; +char (__pyx_k9[]) = "-="; + +static PyObject *__pyx_f_6numpyx_print_array_info(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyObject *__pyx_f_6numpyx_print_array_info(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + PyArrayObject *__pyx_v_arr = 0; + int __pyx_v_i; + PyObject *__pyx_r; + PyObject *__pyx_1 = 0; + PyObject *__pyx_2 = 0; + int __pyx_3; + static char *__pyx_argnames[] = {"arr",0}; + if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O", __pyx_argnames, &__pyx_v_arr)) return 0; + Py_INCREF(__pyx_v_arr); + if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_arr), __pyx_ptype_7c_numpy_ndarray, 1, "arr")) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 10; goto __pyx_L1;} + + /* "/home/fperez/research/wavelets/wavelets/trunk/numpyx/numpyx.pyx":13 */ + __pyx_1 = PyInt_FromLong(10); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 13; goto __pyx_L1;} + __pyx_2 = PyNumber_Multiply(__pyx_k2p, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 13; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + if (__Pyx_PrintItem(__pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 13; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + if (__Pyx_PrintNewline() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 13; goto __pyx_L1;} + + /* "/home/fperez/research/wavelets/wavelets/trunk/numpyx/numpyx.pyx":14 */ + __pyx_1 = PyInt_FromLong(((int )((PyObject *)__pyx_v_arr))); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 14; goto __pyx_L1;} + __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 14; goto __pyx_L1;} + PyTuple_SET_ITEM(__pyx_2, 0, __pyx_1); + __pyx_1 = 0; + __pyx_1 = PyNumber_Remainder(__pyx_k3p, __pyx_2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 14; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + if (__Pyx_PrintItem(__pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 14; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + if (__Pyx_PrintNewline() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 14; goto __pyx_L1;} + + /* "/home/fperez/research/wavelets/wavelets/trunk/numpyx/numpyx.pyx":15 */ + if (__Pyx_PrintItem(__pyx_k4p) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 15; goto __pyx_L1;} + __pyx_2 = PyInt_FromLong(__pyx_v_arr->nd); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 15; goto __pyx_L1;} + if (__Pyx_PrintItem(__pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 15; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + if (__Pyx_PrintNewline() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 15; goto __pyx_L1;} + + /* "/home/fperez/research/wavelets/wavelets/trunk/numpyx/numpyx.pyx":16 */ + __pyx_1 = PyInt_FromLong(((int )__pyx_v_arr->strides)); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 16; goto __pyx_L1;} + __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 16; goto __pyx_L1;} + PyTuple_SET_ITEM(__pyx_2, 0, __pyx_1); + __pyx_1 = 0; + __pyx_1 = PyNumber_Remainder(__pyx_k5p, __pyx_2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 16; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + if (__Pyx_PrintItem(__pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 16; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + if (__Pyx_PrintNewline() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 16; goto __pyx_L1;} + + /* "/home/fperez/research/wavelets/wavelets/trunk/numpyx/numpyx.pyx":17 */ + if (__Pyx_PrintItem(__pyx_k6p) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 17; goto __pyx_L1;} + if (__Pyx_PrintNewline() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 17; goto __pyx_L1;} + + /* "/home/fperez/research/wavelets/wavelets/trunk/numpyx/numpyx.pyx":18 */ + __pyx_3 = __pyx_v_arr->nd; + for (__pyx_v_i = 0; __pyx_v_i < __pyx_3; ++__pyx_v_i) { + + /* "/home/fperez/research/wavelets/wavelets/trunk/numpyx/numpyx.pyx":20 */ + __pyx_2 = PyInt_FromLong(__pyx_v_i); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; goto __pyx_L1;} + __pyx_1 = PyNumber_Remainder(__pyx_k7p, __pyx_2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + if (__Pyx_PrintItem(__pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + __pyx_2 = PyInt_FromLong(((int )(__pyx_v_arr->strides[__pyx_v_i]))); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; goto __pyx_L1;} + if (__Pyx_PrintItem(__pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + if (__Pyx_PrintNewline() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; goto __pyx_L1;} + __pyx_L2:; + } + __pyx_L3:; + + /* "/home/fperez/research/wavelets/wavelets/trunk/numpyx/numpyx.pyx":21 */ + if (__Pyx_PrintItem(__pyx_k8p) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 21; goto __pyx_L1;} + if (__Pyx_PrintNewline() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 21; goto __pyx_L1;} + + /* "/home/fperez/research/wavelets/wavelets/trunk/numpyx/numpyx.pyx":22 */ + __pyx_1 = PyObject_GetAttr(((PyObject *)__pyx_v_arr), __pyx_n_dtype); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 23; goto __pyx_L1;} + __pyx_2 = __pyx_f_6numpyx_print_elements(__pyx_v_arr->data,__pyx_v_arr->strides,__pyx_v_arr->dimensions,__pyx_v_arr->nd,(sizeof(double )),__pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + Py_DECREF(__pyx_2); __pyx_2 = 0; + + /* "/home/fperez/research/wavelets/wavelets/trunk/numpyx/numpyx.pyx":24 */ + __pyx_1 = PyInt_FromLong(10); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; goto __pyx_L1;} + __pyx_2 = PyNumber_Multiply(__pyx_k9p, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + if (__Pyx_PrintItem(__pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + if (__Pyx_PrintNewline() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; goto __pyx_L1;} + + /* "/home/fperez/research/wavelets/wavelets/trunk/numpyx/numpyx.pyx":25 */ + if (__Pyx_PrintNewline() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; goto __pyx_L1;} + + __pyx_r = Py_None; Py_INCREF(__pyx_r); + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + Py_XDECREF(__pyx_2); + __Pyx_AddTraceback("numpyx.print_array_info"); + __pyx_r = 0; + __pyx_L0:; + Py_DECREF(__pyx_v_arr); + return __pyx_r; +} + +static PyObject *__pyx_n_object_; +static PyObject *__pyx_n_float64; +static PyObject *__pyx_n_name; + +static PyObject *__pyx_k10p; +static PyObject *__pyx_k11p; +static PyObject *__pyx_k12p; +static PyObject *__pyx_k13p; +static PyObject *__pyx_k14p; + +char (__pyx_k10[]) = " print_elements() not (yet) implemented for dtype %s"; +char (__pyx_k11[]) = " "; +char (__pyx_k12[]) = " "; +char (__pyx_k13[]) = " "; +char (__pyx_k14[]) = " "; + +static PyObject *__pyx_f_6numpyx_print_elements(char (*__pyx_v_data),int (*__pyx_v_strides),int (*__pyx_v_dimensions),int __pyx_v_nd,int __pyx_v_elsize,PyObject *__pyx_v_dtype) { + int __pyx_v_i; + int __pyx_v_j; + void (*__pyx_v_elptr); + PyObject *__pyx_r; + PyObject *__pyx_1 = 0; + PyObject *__pyx_2 = 0; + PyObject *__pyx_3 = 0; + PyObject *__pyx_4 = 0; + int __pyx_5; + int __pyx_6; + Py_INCREF(__pyx_v_dtype); + + /* "/home/fperez/research/wavelets/wavelets/trunk/numpyx/numpyx.pyx":36 */ + __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_numpy); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; goto __pyx_L1;} + __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_dtype); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_numpy); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; goto __pyx_L1;} + __pyx_3 = PyObject_GetAttr(__pyx_1, __pyx_n_object_); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; goto __pyx_L1;} + PyTuple_SET_ITEM(__pyx_1, 0, __pyx_3); + __pyx_3 = 0; + __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + Py_DECREF(__pyx_1); __pyx_1 = 0; + __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_numpy); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 37; goto __pyx_L1;} + __pyx_1 = PyObject_GetAttr(__pyx_2, __pyx_n_dtype); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 37; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_numpy); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 37; goto __pyx_L1;} + __pyx_4 = PyObject_GetAttr(__pyx_2, __pyx_n_float64); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 37; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 37; goto __pyx_L1;} + PyTuple_SET_ITEM(__pyx_2, 0, __pyx_4); + __pyx_4 = 0; + __pyx_4 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 37; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + Py_DECREF(__pyx_2); __pyx_2 = 0; + __pyx_1 = PyList_New(2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; goto __pyx_L1;} + PyList_SET_ITEM(__pyx_1, 0, __pyx_3); + PyList_SET_ITEM(__pyx_1, 1, __pyx_4); + __pyx_3 = 0; + __pyx_4 = 0; + __pyx_5 = PySequence_Contains(__pyx_1, __pyx_v_dtype); if (__pyx_5 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; goto __pyx_L1;} + __pyx_5 = !__pyx_5; + Py_DECREF(__pyx_1); __pyx_1 = 0; + if (__pyx_5) { + + /* "/home/fperez/research/wavelets/wavelets/trunk/numpyx/numpyx.pyx":38 */ + __pyx_2 = PyObject_GetAttr(__pyx_v_dtype, __pyx_n_name); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 38; goto __pyx_L1;} + __pyx_3 = PyNumber_Remainder(__pyx_k10p, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 38; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + if (__Pyx_PrintItem(__pyx_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 38; goto __pyx_L1;} + Py_DECREF(__pyx_3); __pyx_3 = 0; + if (__Pyx_PrintNewline() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 38; goto __pyx_L1;} + + /* "/home/fperez/research/wavelets/wavelets/trunk/numpyx/numpyx.pyx":39 */ + __pyx_r = Py_None; Py_INCREF(__pyx_r); + goto __pyx_L0; + goto __pyx_L2; + } + __pyx_L2:; + + /* "/home/fperez/research/wavelets/wavelets/trunk/numpyx/numpyx.pyx":41 */ + __pyx_5 = (__pyx_v_nd == 0); + if (__pyx_5) { + + /* "/home/fperez/research/wavelets/wavelets/trunk/numpyx/numpyx.pyx":42 */ + __pyx_4 = __Pyx_GetName(__pyx_m, __pyx_n_numpy); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 42; goto __pyx_L1;} + __pyx_1 = PyObject_GetAttr(__pyx_4, __pyx_n_dtype); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 42; goto __pyx_L1;} + Py_DECREF(__pyx_4); __pyx_4 = 0; + __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_numpy); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 42; goto __pyx_L1;} + __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_object_); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 42; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 42; goto __pyx_L1;} + PyTuple_SET_ITEM(__pyx_4, 0, __pyx_3); + __pyx_3 = 0; + __pyx_2 = PyObject_CallObject(__pyx_1, __pyx_4); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 42; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + Py_DECREF(__pyx_4); __pyx_4 = 0; + if (PyObject_Cmp(__pyx_v_dtype, __pyx_2, &__pyx_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 42; goto __pyx_L1;} + __pyx_5 = __pyx_5 == 0; + Py_DECREF(__pyx_2); __pyx_2 = 0; + if (__pyx_5) { + + /* "/home/fperez/research/wavelets/wavelets/trunk/numpyx/numpyx.pyx":43 */ + __pyx_v_elptr = (((void (*(*)))__pyx_v_data)[0]); + + /* "/home/fperez/research/wavelets/wavelets/trunk/numpyx/numpyx.pyx":44 */ + if (__Pyx_PrintItem(__pyx_k11p) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 44; goto __pyx_L1;} + __pyx_3 = (PyObject *)__pyx_v_elptr; + Py_INCREF(__pyx_3); + if (__Pyx_PrintItem(__pyx_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 44; goto __pyx_L1;} + Py_DECREF(__pyx_3); __pyx_3 = 0; + if (__Pyx_PrintNewline() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 44; goto __pyx_L1;} + goto __pyx_L4; + } + __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_numpy); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; goto __pyx_L1;} + __pyx_4 = PyObject_GetAttr(__pyx_1, __pyx_n_dtype); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_numpy); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; goto __pyx_L1;} + __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_float64); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; goto __pyx_L1;} + PyTuple_SET_ITEM(__pyx_1, 0, __pyx_3); + __pyx_3 = 0; + __pyx_2 = PyObject_CallObject(__pyx_4, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; goto __pyx_L1;} + Py_DECREF(__pyx_4); __pyx_4 = 0; + Py_DECREF(__pyx_1); __pyx_1 = 0; + if (PyObject_Cmp(__pyx_v_dtype, __pyx_2, &__pyx_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; goto __pyx_L1;} + __pyx_5 = __pyx_5 == 0; + Py_DECREF(__pyx_2); __pyx_2 = 0; + if (__pyx_5) { + + /* "/home/fperez/research/wavelets/wavelets/trunk/numpyx/numpyx.pyx":46 */ + if (__Pyx_PrintItem(__pyx_k12p) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 46; goto __pyx_L1;} + __pyx_3 = PyFloat_FromDouble((((double (*))__pyx_v_data)[0])); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 46; goto __pyx_L1;} + if (__Pyx_PrintItem(__pyx_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 46; goto __pyx_L1;} + Py_DECREF(__pyx_3); __pyx_3 = 0; + if (__Pyx_PrintNewline() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 46; goto __pyx_L1;} + goto __pyx_L4; + } + __pyx_L4:; + goto __pyx_L3; + } + __pyx_5 = (__pyx_v_nd == 1); + if (__pyx_5) { + + /* "/home/fperez/research/wavelets/wavelets/trunk/numpyx/numpyx.pyx":48 */ + __pyx_5 = (__pyx_v_dimensions[0]); + for (__pyx_v_i = 0; __pyx_v_i < __pyx_5; ++__pyx_v_i) { + + /* "/home/fperez/research/wavelets/wavelets/trunk/numpyx/numpyx.pyx":49 */ + __pyx_4 = __Pyx_GetName(__pyx_m, __pyx_n_numpy); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; goto __pyx_L1;} + __pyx_1 = PyObject_GetAttr(__pyx_4, __pyx_n_dtype); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; goto __pyx_L1;} + Py_DECREF(__pyx_4); __pyx_4 = 0; + __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_numpy); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; goto __pyx_L1;} + __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_object_); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; goto __pyx_L1;} + PyTuple_SET_ITEM(__pyx_4, 0, __pyx_3); + __pyx_3 = 0; + __pyx_2 = PyObject_CallObject(__pyx_1, __pyx_4); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + Py_DECREF(__pyx_4); __pyx_4 = 0; + if (PyObject_Cmp(__pyx_v_dtype, __pyx_2, &__pyx_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; goto __pyx_L1;} + __pyx_6 = __pyx_6 == 0; + Py_DECREF(__pyx_2); __pyx_2 = 0; + if (__pyx_6) { + + /* "/home/fperez/research/wavelets/wavelets/trunk/numpyx/numpyx.pyx":50 */ + __pyx_v_elptr = (((void (*(*)))__pyx_v_data)[0]); + + /* "/home/fperez/research/wavelets/wavelets/trunk/numpyx/numpyx.pyx":51 */ + if (__Pyx_PrintItem(__pyx_k13p) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 51; goto __pyx_L1;} + __pyx_3 = (PyObject *)__pyx_v_elptr; + Py_INCREF(__pyx_3); + if (__Pyx_PrintItem(__pyx_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 51; goto __pyx_L1;} + Py_DECREF(__pyx_3); __pyx_3 = 0; + if (__Pyx_PrintNewline() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 51; goto __pyx_L1;} + goto __pyx_L7; + } + __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_numpy); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 52; goto __pyx_L1;} + __pyx_4 = PyObject_GetAttr(__pyx_1, __pyx_n_dtype); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 52; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_numpy); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 52; goto __pyx_L1;} + __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_float64); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 52; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 52; goto __pyx_L1;} + PyTuple_SET_ITEM(__pyx_1, 0, __pyx_3); + __pyx_3 = 0; + __pyx_2 = PyObject_CallObject(__pyx_4, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 52; goto __pyx_L1;} + Py_DECREF(__pyx_4); __pyx_4 = 0; + Py_DECREF(__pyx_1); __pyx_1 = 0; + if (PyObject_Cmp(__pyx_v_dtype, __pyx_2, &__pyx_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 52; goto __pyx_L1;} + __pyx_6 = __pyx_6 == 0; + Py_DECREF(__pyx_2); __pyx_2 = 0; + if (__pyx_6) { + + /* "/home/fperez/research/wavelets/wavelets/trunk/numpyx/numpyx.pyx":53 */ + if (__Pyx_PrintItem(__pyx_k14p) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; goto __pyx_L1;} + __pyx_3 = PyFloat_FromDouble((((double (*))__pyx_v_data)[0])); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; goto __pyx_L1;} + if (__Pyx_PrintItem(__pyx_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; goto __pyx_L1;} + Py_DECREF(__pyx_3); __pyx_3 = 0; + if (__Pyx_PrintNewline() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; goto __pyx_L1;} + goto __pyx_L7; + } + __pyx_L7:; + + /* "/home/fperez/research/wavelets/wavelets/trunk/numpyx/numpyx.pyx":54 */ + __pyx_v_data = (__pyx_v_data + (__pyx_v_strides[0])); + __pyx_L5:; + } + __pyx_L6:; + goto __pyx_L3; + } + /*else*/ { + + /* "/home/fperez/research/wavelets/wavelets/trunk/numpyx/numpyx.pyx":56 */ + __pyx_6 = (__pyx_v_dimensions[0]); + for (__pyx_v_i = 0; __pyx_v_i < __pyx_6; ++__pyx_v_i) { + + /* "/home/fperez/research/wavelets/wavelets/trunk/numpyx/numpyx.pyx":57 */ + __pyx_4 = __pyx_f_6numpyx_print_elements(__pyx_v_data,(__pyx_v_strides + 1),(__pyx_v_dimensions + 1),(__pyx_v_nd - 1),__pyx_v_elsize,__pyx_v_dtype); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 57; goto __pyx_L1;} + Py_DECREF(__pyx_4); __pyx_4 = 0; + + /* "/home/fperez/research/wavelets/wavelets/trunk/numpyx/numpyx.pyx":58 */ + __pyx_v_data = (__pyx_v_data + (__pyx_v_strides[0])); + __pyx_L8:; + } + __pyx_L9:; + } + __pyx_L3:; + + __pyx_r = Py_None; Py_INCREF(__pyx_r); + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + Py_XDECREF(__pyx_2); + Py_XDECREF(__pyx_3); + Py_XDECREF(__pyx_4); + __Pyx_AddTraceback("numpyx.print_elements"); + __pyx_r = 0; + __pyx_L0:; + Py_DECREF(__pyx_v_dtype); + return __pyx_r; +} + +static PyObject *__pyx_n_any; + +static PyObject *__pyx_k15p; +static PyObject *__pyx_k16p; +static PyObject *__pyx_k17p; + +char (__pyx_k15[]) = "arr.any() :"; +char (__pyx_k16[]) = "arr.nd :"; +char (__pyx_k17[]) = "arr.flags :"; + +static PyObject *__pyx_f_6numpyx_test_methods(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static char __pyx_doc_6numpyx_test_methods[] = "Test a few attribute accesses for an array.\n \n This illustrates how the pyrex-visible object is in practice a strange\n hybrid of the C PyArrayObject struct and the python object. Some\n properties (like .nd) are visible here but not in python, while others\n like flags behave very differently: in python flags appears as a dict,\n while here we see the raw int holding the bit pattern.\n\n This makes sense when we think of how pyrex resolves arr.foo: if foo is\n listed as a field in the c_numpy.ndarray struct description, it will be\n directly accessed as a C variable without going through Python at all.\n This is why for arr.flags, we see the actual int which holds all the flags\n as bit fields. However, for any other attribute not listed in the struct,\n it simply forwards the attribute lookup to python at runtime, just like\n python would (which means that AttributeError can be raised for\n non-existent attributes, for example)."; +static PyObject *__pyx_f_6numpyx_test_methods(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + PyArrayObject *__pyx_v_arr = 0; + PyObject *__pyx_r; + PyObject *__pyx_1 = 0; + PyObject *__pyx_2 = 0; + PyObject *__pyx_3 = 0; + static char *__pyx_argnames[] = {"arr",0}; + if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O", __pyx_argnames, &__pyx_v_arr)) return 0; + Py_INCREF(__pyx_v_arr); + if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_arr), __pyx_ptype_7c_numpy_ndarray, 1, "arr")) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 60; goto __pyx_L1;} + + /* "/home/fperez/research/wavelets/wavelets/trunk/numpyx/numpyx.pyx":78 */ + if (__Pyx_PrintItem(__pyx_k15p) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 78; goto __pyx_L1;} + __pyx_1 = PyObject_GetAttr(((PyObject *)__pyx_v_arr), __pyx_n_any); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 78; goto __pyx_L1;} + __pyx_2 = PyTuple_New(0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 78; goto __pyx_L1;} + __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 78; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + Py_DECREF(__pyx_2); __pyx_2 = 0; + if (__Pyx_PrintItem(__pyx_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 78; goto __pyx_L1;} + Py_DECREF(__pyx_3); __pyx_3 = 0; + if (__Pyx_PrintNewline() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 78; goto __pyx_L1;} + + /* "/home/fperez/research/wavelets/wavelets/trunk/numpyx/numpyx.pyx":79 */ + if (__Pyx_PrintItem(__pyx_k16p) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 79; goto __pyx_L1;} + __pyx_1 = PyInt_FromLong(__pyx_v_arr->nd); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 79; goto __pyx_L1;} + if (__Pyx_PrintItem(__pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 79; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + if (__Pyx_PrintNewline() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 79; goto __pyx_L1;} + + /* "/home/fperez/research/wavelets/wavelets/trunk/numpyx/numpyx.pyx":80 */ + if (__Pyx_PrintItem(__pyx_k17p) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 80; goto __pyx_L1;} + __pyx_2 = PyInt_FromLong(__pyx_v_arr->flags); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 80; goto __pyx_L1;} + if (__Pyx_PrintItem(__pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 80; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + if (__Pyx_PrintNewline() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 80; goto __pyx_L1;} + + __pyx_r = Py_None; Py_INCREF(__pyx_r); + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + Py_XDECREF(__pyx_2); + Py_XDECREF(__pyx_3); + __Pyx_AddTraceback("numpyx.test_methods"); + __pyx_r = 0; + __pyx_L0:; + Py_DECREF(__pyx_v_arr); + return __pyx_r; +} + +static PyObject *__pyx_n_array; +static PyObject *__pyx_n_Float64; +static PyObject *__pyx_n_arange; +static PyObject *__pyx_n_shape; +static PyObject *__pyx_n_one; +static PyObject *__pyx_n_two; + + +static PyObject *__pyx_f_6numpyx_test(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static char __pyx_doc_6numpyx_test[] = "this function is pure Python"; +static PyObject *__pyx_f_6numpyx_test(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + PyObject *__pyx_v_arr1; + PyObject *__pyx_v_arr2; + PyObject *__pyx_v_arr3; + PyObject *__pyx_v_four; + PyObject *__pyx_v_arr4; + PyObject *__pyx_v_arr5; + PyObject *__pyx_v_arr; + PyObject *__pyx_r; + PyObject *__pyx_1 = 0; + PyObject *__pyx_2 = 0; + PyObject *__pyx_3 = 0; + PyObject *__pyx_4 = 0; + PyObject *__pyx_5 = 0; + static char *__pyx_argnames[] = {0}; + if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) return 0; + __pyx_v_arr1 = Py_None; Py_INCREF(__pyx_v_arr1); + __pyx_v_arr2 = Py_None; Py_INCREF(__pyx_v_arr2); + __pyx_v_arr3 = Py_None; Py_INCREF(__pyx_v_arr3); + __pyx_v_four = Py_None; Py_INCREF(__pyx_v_four); + __pyx_v_arr4 = Py_None; Py_INCREF(__pyx_v_arr4); + __pyx_v_arr5 = Py_None; Py_INCREF(__pyx_v_arr5); + __pyx_v_arr = Py_None; Py_INCREF(__pyx_v_arr); + + /* "/home/fperez/research/wavelets/wavelets/trunk/numpyx/numpyx.pyx":84 */ + __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_numpy); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; goto __pyx_L1;} + __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_array); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + __pyx_1 = PyFloat_FromDouble((-1e-30)); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; goto __pyx_L1;} + __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; goto __pyx_L1;} + PyTuple_SET_ITEM(__pyx_3, 0, __pyx_1); + __pyx_1 = 0; + __pyx_1 = PyDict_New(); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; goto __pyx_L1;} + __pyx_4 = __Pyx_GetName(__pyx_m, __pyx_n_numpy); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; goto __pyx_L1;} + __pyx_5 = PyObject_GetAttr(__pyx_4, __pyx_n_Float64); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; goto __pyx_L1;} + Py_DECREF(__pyx_4); __pyx_4 = 0; + if (PyDict_SetItem(__pyx_1, __pyx_n_dtype, __pyx_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; goto __pyx_L1;} + Py_DECREF(__pyx_5); __pyx_5 = 0; + __pyx_4 = PyEval_CallObjectWithKeywords(__pyx_2, __pyx_3, __pyx_1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + Py_DECREF(__pyx_3); __pyx_3 = 0; + Py_DECREF(__pyx_1); __pyx_1 = 0; + Py_DECREF(__pyx_v_arr1); + __pyx_v_arr1 = __pyx_4; + __pyx_4 = 0; + + /* "/home/fperez/research/wavelets/wavelets/trunk/numpyx/numpyx.pyx":85 */ + __pyx_5 = __Pyx_GetName(__pyx_m, __pyx_n_numpy); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 85; goto __pyx_L1;} + __pyx_2 = PyObject_GetAttr(__pyx_5, __pyx_n_array); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 85; goto __pyx_L1;} + Py_DECREF(__pyx_5); __pyx_5 = 0; + __pyx_3 = PyFloat_FromDouble(1.0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 85; goto __pyx_L1;} + __pyx_1 = PyFloat_FromDouble(2.0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 85; goto __pyx_L1;} + __pyx_4 = PyFloat_FromDouble(3.0); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 85; goto __pyx_L1;} + __pyx_5 = PyList_New(3); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 85; goto __pyx_L1;} + PyList_SET_ITEM(__pyx_5, 0, __pyx_3); + PyList_SET_ITEM(__pyx_5, 1, __pyx_1); + PyList_SET_ITEM(__pyx_5, 2, __pyx_4); + __pyx_3 = 0; + __pyx_1 = 0; + __pyx_4 = 0; + __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 85; goto __pyx_L1;} + PyTuple_SET_ITEM(__pyx_3, 0, __pyx_5); + __pyx_5 = 0; + __pyx_1 = PyDict_New(); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 85; goto __pyx_L1;} + __pyx_4 = __Pyx_GetName(__pyx_m, __pyx_n_numpy); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 85; goto __pyx_L1;} + __pyx_5 = PyObject_GetAttr(__pyx_4, __pyx_n_Float64); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 85; goto __pyx_L1;} + Py_DECREF(__pyx_4); __pyx_4 = 0; + if (PyDict_SetItem(__pyx_1, __pyx_n_dtype, __pyx_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 85; goto __pyx_L1;} + Py_DECREF(__pyx_5); __pyx_5 = 0; + __pyx_4 = PyEval_CallObjectWithKeywords(__pyx_2, __pyx_3, __pyx_1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 85; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + Py_DECREF(__pyx_3); __pyx_3 = 0; + Py_DECREF(__pyx_1); __pyx_1 = 0; + Py_DECREF(__pyx_v_arr2); + __pyx_v_arr2 = __pyx_4; + __pyx_4 = 0; + + /* "/home/fperez/research/wavelets/wavelets/trunk/numpyx/numpyx.pyx":87 */ + __pyx_5 = __Pyx_GetName(__pyx_m, __pyx_n_numpy); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 87; goto __pyx_L1;} + __pyx_2 = PyObject_GetAttr(__pyx_5, __pyx_n_arange); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 87; goto __pyx_L1;} + Py_DECREF(__pyx_5); __pyx_5 = 0; + __pyx_3 = PyInt_FromLong(9); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 87; goto __pyx_L1;} + __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 87; goto __pyx_L1;} + PyTuple_SET_ITEM(__pyx_1, 0, __pyx_3); + __pyx_3 = 0; + __pyx_4 = PyDict_New(); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 87; goto __pyx_L1;} + __pyx_5 = __Pyx_GetName(__pyx_m, __pyx_n_numpy); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 87; goto __pyx_L1;} + __pyx_3 = PyObject_GetAttr(__pyx_5, __pyx_n_Float64); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 87; goto __pyx_L1;} + Py_DECREF(__pyx_5); __pyx_5 = 0; + if (PyDict_SetItem(__pyx_4, __pyx_n_dtype, __pyx_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 87; goto __pyx_L1;} + Py_DECREF(__pyx_3); __pyx_3 = 0; + __pyx_5 = PyEval_CallObjectWithKeywords(__pyx_2, __pyx_1, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 87; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + Py_DECREF(__pyx_1); __pyx_1 = 0; + Py_DECREF(__pyx_4); __pyx_4 = 0; + Py_DECREF(__pyx_v_arr3); + __pyx_v_arr3 = __pyx_5; + __pyx_5 = 0; + + /* "/home/fperez/research/wavelets/wavelets/trunk/numpyx/numpyx.pyx":88 */ + __pyx_3 = PyInt_FromLong(3); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 88; goto __pyx_L1;} + __pyx_2 = PyInt_FromLong(3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 88; goto __pyx_L1;} + __pyx_1 = PyTuple_New(2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 88; goto __pyx_L1;} + PyTuple_SET_ITEM(__pyx_1, 0, __pyx_3); + PyTuple_SET_ITEM(__pyx_1, 1, __pyx_2); + __pyx_3 = 0; + __pyx_2 = 0; + if (PyObject_SetAttr(__pyx_v_arr3, __pyx_n_shape, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 88; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + + /* "/home/fperez/research/wavelets/wavelets/trunk/numpyx/numpyx.pyx":90 */ + __pyx_4 = PyInt_FromLong(4); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; goto __pyx_L1;} + Py_DECREF(__pyx_v_four); + __pyx_v_four = __pyx_4; + __pyx_4 = 0; + + /* "/home/fperez/research/wavelets/wavelets/trunk/numpyx/numpyx.pyx":91 */ + __pyx_5 = __Pyx_GetName(__pyx_m, __pyx_n_numpy); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 91; goto __pyx_L1;} + __pyx_3 = PyObject_GetAttr(__pyx_5, __pyx_n_array); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 91; goto __pyx_L1;} + Py_DECREF(__pyx_5); __pyx_5 = 0; + __pyx_2 = PyInt_FromLong(3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 91; goto __pyx_L1;} + __pyx_1 = PyList_New(4); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 91; goto __pyx_L1;} + Py_INCREF(__pyx_n_one); + PyList_SET_ITEM(__pyx_1, 0, __pyx_n_one); + Py_INCREF(__pyx_n_two); + PyList_SET_ITEM(__pyx_1, 1, __pyx_n_two); + PyList_SET_ITEM(__pyx_1, 2, __pyx_2); + Py_INCREF(__pyx_v_four); + PyList_SET_ITEM(__pyx_1, 3, __pyx_v_four); + __pyx_2 = 0; + __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 91; goto __pyx_L1;} + PyTuple_SET_ITEM(__pyx_4, 0, __pyx_1); + __pyx_1 = 0; + __pyx_5 = PyDict_New(); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 91; goto __pyx_L1;} + __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_numpy); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 91; goto __pyx_L1;} + __pyx_1 = PyObject_GetAttr(__pyx_2, __pyx_n_object_); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 91; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + if (PyDict_SetItem(__pyx_5, __pyx_n_dtype, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 91; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + __pyx_2 = PyEval_CallObjectWithKeywords(__pyx_3, __pyx_4, __pyx_5); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 91; goto __pyx_L1;} + Py_DECREF(__pyx_3); __pyx_3 = 0; + Py_DECREF(__pyx_4); __pyx_4 = 0; + Py_DECREF(__pyx_5); __pyx_5 = 0; + Py_DECREF(__pyx_v_arr4); + __pyx_v_arr4 = __pyx_2; + __pyx_2 = 0; + + /* "/home/fperez/research/wavelets/wavelets/trunk/numpyx/numpyx.pyx":93 */ + __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_numpy); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 93; goto __pyx_L1;} + __pyx_3 = PyObject_GetAttr(__pyx_1, __pyx_n_array); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 93; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + __pyx_4 = PyInt_FromLong(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 93; goto __pyx_L1;} + __pyx_5 = PyInt_FromLong(2); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 93; goto __pyx_L1;} + __pyx_2 = PyInt_FromLong(3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 93; goto __pyx_L1;} + __pyx_1 = PyList_New(3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 93; goto __pyx_L1;} + PyList_SET_ITEM(__pyx_1, 0, __pyx_4); + PyList_SET_ITEM(__pyx_1, 1, __pyx_5); + PyList_SET_ITEM(__pyx_1, 2, __pyx_2); + __pyx_4 = 0; + __pyx_5 = 0; + __pyx_2 = 0; + __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 93; goto __pyx_L1;} + PyTuple_SET_ITEM(__pyx_4, 0, __pyx_1); + __pyx_1 = 0; + __pyx_5 = PyObject_CallObject(__pyx_3, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 93; goto __pyx_L1;} + Py_DECREF(__pyx_3); __pyx_3 = 0; + Py_DECREF(__pyx_4); __pyx_4 = 0; + Py_DECREF(__pyx_v_arr5); + __pyx_v_arr5 = __pyx_5; + __pyx_5 = 0; + + /* "/home/fperez/research/wavelets/wavelets/trunk/numpyx/numpyx.pyx":95 */ + __pyx_2 = PyList_New(5); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 95; goto __pyx_L1;} + Py_INCREF(__pyx_v_arr1); + PyList_SET_ITEM(__pyx_2, 0, __pyx_v_arr1); + Py_INCREF(__pyx_v_arr2); + PyList_SET_ITEM(__pyx_2, 1, __pyx_v_arr2); + Py_INCREF(__pyx_v_arr3); + PyList_SET_ITEM(__pyx_2, 2, __pyx_v_arr3); + Py_INCREF(__pyx_v_arr4); + PyList_SET_ITEM(__pyx_2, 3, __pyx_v_arr4); + Py_INCREF(__pyx_v_arr5); + PyList_SET_ITEM(__pyx_2, 4, __pyx_v_arr5); + __pyx_1 = PyObject_GetIter(__pyx_2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 95; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + for (;;) { + __pyx_L2:; + __pyx_3 = PyIter_Next(__pyx_1); + if (!__pyx_3) { + if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 95; goto __pyx_L1;} + break; + } + Py_DECREF(__pyx_v_arr); + __pyx_v_arr = __pyx_3; + __pyx_3 = 0; + + /* "/home/fperez/research/wavelets/wavelets/trunk/numpyx/numpyx.pyx":96 */ + __pyx_4 = __Pyx_GetName(__pyx_m, __pyx_n_print_array_info); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 96; goto __pyx_L1;} + __pyx_5 = PyTuple_New(1); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 96; goto __pyx_L1;} + Py_INCREF(__pyx_v_arr); + PyTuple_SET_ITEM(__pyx_5, 0, __pyx_v_arr); + __pyx_2 = PyObject_CallObject(__pyx_4, __pyx_5); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 96; goto __pyx_L1;} + Py_DECREF(__pyx_4); __pyx_4 = 0; + Py_DECREF(__pyx_5); __pyx_5 = 0; + Py_DECREF(__pyx_2); __pyx_2 = 0; + } + __pyx_L3:; + Py_DECREF(__pyx_1); __pyx_1 = 0; + + __pyx_r = Py_None; Py_INCREF(__pyx_r); + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + Py_XDECREF(__pyx_2); + Py_XDECREF(__pyx_3); + Py_XDECREF(__pyx_4); + Py_XDECREF(__pyx_5); + __Pyx_AddTraceback("numpyx.test"); + __pyx_r = 0; + __pyx_L0:; + Py_DECREF(__pyx_v_arr1); + Py_DECREF(__pyx_v_arr2); + Py_DECREF(__pyx_v_arr3); + Py_DECREF(__pyx_v_four); + Py_DECREF(__pyx_v_arr4); + Py_DECREF(__pyx_v_arr5); + Py_DECREF(__pyx_v_arr); + return __pyx_r; +} + +static __Pyx_InternTabEntry __pyx_intern_tab[] = { + {&__pyx_n_Float64, "Float64"}, + {&__pyx_n_any, "any"}, + {&__pyx_n_arange, "arange"}, + {&__pyx_n_array, "array"}, + {&__pyx_n_c_numpy, "c_numpy"}, + {&__pyx_n_c_python, "c_python"}, + {&__pyx_n_dtype, "dtype"}, + {&__pyx_n_float64, "float64"}, + {&__pyx_n_name, "name"}, + {&__pyx_n_numpy, "numpy"}, + {&__pyx_n_object_, "object_"}, + {&__pyx_n_one, "one"}, + {&__pyx_n_print_array_info, "print_array_info"}, + {&__pyx_n_shape, "shape"}, + {&__pyx_n_test, "test"}, + {&__pyx_n_test_methods, "test_methods"}, + {&__pyx_n_two, "two"}, + {0, 0} +}; + +static __Pyx_StringTabEntry __pyx_string_tab[] = { + {&__pyx_k2p, __pyx_k2, sizeof(__pyx_k2)}, + {&__pyx_k3p, __pyx_k3, sizeof(__pyx_k3)}, + {&__pyx_k4p, __pyx_k4, sizeof(__pyx_k4)}, + {&__pyx_k5p, __pyx_k5, sizeof(__pyx_k5)}, + {&__pyx_k6p, __pyx_k6, sizeof(__pyx_k6)}, + {&__pyx_k7p, __pyx_k7, sizeof(__pyx_k7)}, + {&__pyx_k8p, __pyx_k8, sizeof(__pyx_k8)}, + {&__pyx_k9p, __pyx_k9, sizeof(__pyx_k9)}, + {&__pyx_k10p, __pyx_k10, sizeof(__pyx_k10)}, + {&__pyx_k11p, __pyx_k11, sizeof(__pyx_k11)}, + {&__pyx_k12p, __pyx_k12, sizeof(__pyx_k12)}, + {&__pyx_k13p, __pyx_k13, sizeof(__pyx_k13)}, + {&__pyx_k14p, __pyx_k14, sizeof(__pyx_k14)}, + {&__pyx_k15p, __pyx_k15, sizeof(__pyx_k15)}, + {&__pyx_k16p, __pyx_k16, sizeof(__pyx_k16)}, + {&__pyx_k17p, __pyx_k17, sizeof(__pyx_k17)}, + {0, 0, 0} +}; + +static struct PyMethodDef __pyx_methods[] = { + {"print_array_info", (PyCFunction)__pyx_f_6numpyx_print_array_info, METH_VARARGS|METH_KEYWORDS, 0}, + {"test_methods", (PyCFunction)__pyx_f_6numpyx_test_methods, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6numpyx_test_methods}, + {"test", (PyCFunction)__pyx_f_6numpyx_test, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6numpyx_test}, + {0, 0, 0, 0} +}; + +DL_EXPORT(void) initnumpyx(void); /*proto*/ +DL_EXPORT(void) initnumpyx(void) { + PyObject *__pyx_1 = 0; + __pyx_m = Py_InitModule4("numpyx", __pyx_methods, 0, 0, PYTHON_API_VERSION); + if (!__pyx_m) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3; goto __pyx_L1;}; + __pyx_b = PyImport_AddModule("__builtin__"); + if (!__pyx_b) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3; goto __pyx_L1;}; + if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3; goto __pyx_L1;}; + if (__Pyx_InternStrings(__pyx_intern_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3; goto __pyx_L1;}; + if (__Pyx_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3; goto __pyx_L1;}; + __pyx_ptype_7c_numpy_dtype = __Pyx_ImportType("numpy", "dtype", sizeof(PyArray_Descr)); if (!__pyx_ptype_7c_numpy_dtype) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 35; goto __pyx_L1;} + __pyx_ptype_7c_numpy_ndarray = __Pyx_ImportType("numpy", "ndarray", sizeof(PyArrayObject)); if (!__pyx_ptype_7c_numpy_ndarray) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 39; goto __pyx_L1;} + + /* "/home/fperez/research/wavelets/wavelets/trunk/numpyx/numpyx.pyx":5 */ + __pyx_1 = __Pyx_Import(__pyx_n_numpy, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5; goto __pyx_L1;} + if (PyObject_SetAttr(__pyx_m, __pyx_n_numpy, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + + /* "/home/fperez/research/wavelets/wavelets/trunk/numpyx/numpyx.pyx":8 */ + import_array(); + + /* "/home/fperez/research/wavelets/wavelets/trunk/numpyx/numpyx.pyx":82 */ + return; + __pyx_L1:; + Py_XDECREF(__pyx_1); + __Pyx_AddTraceback("numpyx"); +} + +static char *__pyx_filenames[] = { + "numpyx.pyx", + "c_numpy.pxd", +}; +statichere char **__pyx_f = __pyx_filenames; + +/* Runtime support code */ + +static int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed, char *name) { + if (!type) { + PyErr_Format(PyExc_SystemError, "Missing type object"); + return 0; + } + if ((none_allowed && obj == Py_None) || PyObject_TypeCheck(obj, type)) + return 1; + PyErr_Format(PyExc_TypeError, + "Argument '%s' has incorrect type (expected %s, got %s)", + name, type->tp_name, obj->ob_type->tp_name); + return 0; +} + +static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list) { + PyObject *__import__ = 0; + PyObject *empty_list = 0; + PyObject *module = 0; + PyObject *global_dict = 0; + PyObject *empty_dict = 0; + PyObject *list; + __import__ = PyObject_GetAttrString(__pyx_b, "__import__"); + if (!__import__) + goto bad; + if (from_list) + list = from_list; + else { + empty_list = PyList_New(0); + if (!empty_list) + goto bad; + list = empty_list; + } + global_dict = PyModule_GetDict(__pyx_m); + if (!global_dict) + goto bad; + empty_dict = PyDict_New(); + if (!empty_dict) + goto bad; + module = PyObject_CallFunction(__import__, "OOOO", + name, global_dict, empty_dict, list); +bad: + Py_XDECREF(empty_list); + Py_XDECREF(__import__); + Py_XDECREF(empty_dict); + return module; +} + +static PyObject *__Pyx_GetStdout(void) { + PyObject *f = PySys_GetObject("stdout"); + if (!f) { + PyErr_SetString(PyExc_RuntimeError, "lost sys.stdout"); + } + return f; +} + +static int __Pyx_PrintItem(PyObject *v) { + PyObject *f; + + if (!(f = __Pyx_GetStdout())) + return -1; + if (PyFile_SoftSpace(f, 1)) { + if (PyFile_WriteString(" ", f) < 0) + return -1; + } + if (PyFile_WriteObject(v, f, Py_PRINT_RAW) < 0) + return -1; + if (PyString_Check(v)) { + char *s = PyString_AsString(v); + int len = PyString_Size(v); + if (len > 0 && + isspace(Py_CHARMASK(s[len-1])) && + s[len-1] != ' ') + PyFile_SoftSpace(f, 0); + } + return 0; +} + +static int __Pyx_PrintNewline(void) { + PyObject *f; + + if (!(f = __Pyx_GetStdout())) + return -1; + if (PyFile_WriteString("\n", f) < 0) + return -1; + PyFile_SoftSpace(f, 0); + return 0; +} + +static PyObject *__Pyx_GetName(PyObject *dict, PyObject *name) { + PyObject *result; + result = PyObject_GetAttr(dict, name); + if (!result) + PyErr_SetObject(PyExc_NameError, name); + return result; +} + +static int __Pyx_InternStrings(__Pyx_InternTabEntry *t) { + while (t->p) { + *t->p = PyString_InternFromString(t->s); + if (!*t->p) + return -1; + ++t; + } + return 0; +} + +static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) { + while (t->p) { + *t->p = PyString_FromStringAndSize(t->s, t->n - 1); + if (!*t->p) + return -1; + ++t; + } + return 0; +} + +static PyTypeObject *__Pyx_ImportType(char *module_name, char *class_name, + long size) +{ + PyObject *py_module_name = 0; + PyObject *py_class_name = 0; + PyObject *py_name_list = 0; + PyObject *py_module = 0; + PyObject *result = 0; + + py_module_name = PyString_FromString(module_name); + if (!py_module_name) + goto bad; + py_class_name = PyString_FromString(class_name); + if (!py_class_name) + goto bad; + py_name_list = PyList_New(1); + if (!py_name_list) + goto bad; + Py_INCREF(py_class_name); + if (PyList_SetItem(py_name_list, 0, py_class_name) < 0) + goto bad; + py_module = __Pyx_Import(py_module_name, py_name_list); + if (!py_module) + goto bad; + result = PyObject_GetAttr(py_module, py_class_name); + if (!result) + goto bad; + if (!PyType_Check(result)) { + PyErr_Format(PyExc_TypeError, + "%s.%s is not a type object", + module_name, class_name); + goto bad; + } + if (((PyTypeObject *)result)->tp_basicsize != size) { + PyErr_Format(PyExc_ValueError, + "%s.%s does not appear to be the correct type object", + module_name, class_name); + goto bad; + } + goto done; +bad: + Py_XDECREF(result); + result = 0; +done: + Py_XDECREF(py_module_name); + Py_XDECREF(py_class_name); + Py_XDECREF(py_name_list); + return (PyTypeObject *)result; +} + +#include "compile.h" +#include "frameobject.h" +#include "traceback.h" + +static void __Pyx_AddTraceback(char *funcname) { + PyObject *py_srcfile = 0; + PyObject *py_funcname = 0; + PyObject *py_globals = 0; + PyObject *empty_tuple = 0; + PyObject *empty_string = 0; + PyCodeObject *py_code = 0; + PyFrameObject *py_frame = 0; + + py_srcfile = PyString_FromString(__pyx_filename); + if (!py_srcfile) goto bad; + py_funcname = PyString_FromString(funcname); + if (!py_funcname) goto bad; + py_globals = PyModule_GetDict(__pyx_m); + if (!py_globals) goto bad; + empty_tuple = PyTuple_New(0); + if (!empty_tuple) goto bad; + empty_string = PyString_FromString(""); + if (!empty_string) goto bad; + py_code = PyCode_New( + 0, /*int argcount,*/ + 0, /*int nlocals,*/ + 0, /*int stacksize,*/ + 0, /*int flags,*/ + empty_string, /*PyObject *code,*/ + empty_tuple, /*PyObject *consts,*/ + empty_tuple, /*PyObject *names,*/ + empty_tuple, /*PyObject *varnames,*/ + empty_tuple, /*PyObject *freevars,*/ + empty_tuple, /*PyObject *cellvars,*/ + py_srcfile, /*PyObject *filename,*/ + py_funcname, /*PyObject *name,*/ + __pyx_lineno, /*int firstlineno,*/ + empty_string /*PyObject *lnotab*/ + ); + if (!py_code) goto bad; + py_frame = PyFrame_New( + PyThreadState_Get(), /*PyThreadState *tstate,*/ + py_code, /*PyCodeObject *code,*/ + py_globals, /*PyObject *globals,*/ + 0 /*PyObject *locals*/ + ); + if (!py_frame) goto bad; + py_frame->f_lineno = __pyx_lineno; + PyTraceBack_Here(py_frame); +bad: + Py_XDECREF(py_srcfile); + Py_XDECREF(py_funcname); + Py_XDECREF(empty_tuple); + Py_XDECREF(empty_string); + Py_XDECREF(py_code); + Py_XDECREF(py_frame); +} diff --git a/numpy/doc/pyrex/numpyx.pyx b/numpy/doc/pyrex/numpyx.pyx new file mode 100644 index 000000000..4cd6dbd29 --- /dev/null +++ b/numpy/doc/pyrex/numpyx.pyx @@ -0,0 +1,97 @@ +# -*- Mode: Python -*- Not really, but close enough + +cimport c_python +cimport c_numpy +import numpy + +# Numpy must be initialized +c_numpy.import_array() + +def print_array_info(c_numpy.ndarray arr): + cdef int i + + print '-='*10 + print 'printing array info for ndarray at 0x%0lx'%(<c_python.Py_intptr_t>arr,) + print 'print number of dimensions:',arr.nd + print 'address of strides: 0x%0lx'%(<c_python.Py_intptr_t>arr.strides,) + print 'strides:' + for i from 0<=i<arr.nd: + # print each stride + print ' stride %d:'%i,<c_python.Py_intptr_t>arr.strides[i] + print 'memory dump:' + print_elements( arr.data, arr.strides, arr.dimensions, + arr.nd, sizeof(double), arr.dtype ) + print '-='*10 + print + +cdef print_elements(char *data, + c_python.Py_intptr_t* strides, + c_python.Py_intptr_t* dimensions, + int nd, + int elsize, + object dtype): + cdef c_python.Py_intptr_t i,j + cdef void* elptr + + if dtype not in [numpy.dtype(numpy.object_), + numpy.dtype(numpy.float64)]: + print ' print_elements() not (yet) implemented for dtype %s'%dtype.name + return + + if nd ==0: + if dtype==numpy.dtype(numpy.object_): + elptr = (<void**>data)[0] #[0] dereferences pointer in Pyrex + print ' ',<object>elptr + elif dtype==numpy.dtype(numpy.float64): + print ' ',(<double*>data)[0] + elif nd == 1: + for i from 0<=i<dimensions[0]: + if dtype==numpy.dtype(numpy.object_): + elptr = (<void**>data)[0] + print ' ',<object>elptr + elif dtype==numpy.dtype(numpy.float64): + print ' ',(<double*>data)[0] + data = data + strides[0] + else: + for i from 0<=i<dimensions[0]: + print_elements(data, strides+1, dimensions+1, nd-1, elsize, dtype) + data = data + strides[0] + +def test_methods(c_numpy.ndarray arr): + """Test a few attribute accesses for an array. + + This illustrates how the pyrex-visible object is in practice a strange + hybrid of the C PyArrayObject struct and the python object. Some + properties (like .nd) are visible here but not in python, while others + like flags behave very differently: in python flags appears as a dict, + while here we see the raw int holding the bit pattern. + + This makes sense when we think of how pyrex resolves arr.foo: if foo is + listed as a field in the c_numpy.ndarray struct description, it will be + directly accessed as a C variable without going through Python at all. + This is why for arr.flags, we see the actual int which holds all the flags + as bit fields. However, for any other attribute not listed in the struct, + it simply forwards the attribute lookup to python at runtime, just like + python would (which means that AttributeError can be raised for + non-existent attributes, for example).""" + + print 'arr.any() :',arr.any() + print 'arr.nd :',arr.nd + print 'arr.flags :',arr.flags + +def test(): + """this function is pure Python""" + arr1 = numpy.array(-1e-30,dtype=numpy.Float64) + arr2 = numpy.array([1.0,2.0,3.0],dtype=numpy.Float64) + + arr3 = numpy.arange(9,dtype=numpy.Float64) + arr3.shape = 3,3 + + four = 4 + arr4 = numpy.array(['one','two',3,four],dtype=numpy.object_) + + arr5 = numpy.array([1,2,3]) # int types not (yet) supported by print_elements + + for arr in [arr1,arr2,arr3,arr4,arr5]: + print_array_info(arr) + diff --git a/numpy/doc/pyrex/run_test.py b/numpy/doc/pyrex/run_test.py new file mode 100755 index 000000000..96388011e --- /dev/null +++ b/numpy/doc/pyrex/run_test.py @@ -0,0 +1,3 @@ +#!/usr/bin/env python +from numpyx import test +test() diff --git a/numpy/doc/pyrex/setup.py b/numpy/doc/pyrex/setup.py new file mode 100644 index 000000000..d081080d3 --- /dev/null +++ b/numpy/doc/pyrex/setup.py @@ -0,0 +1,42 @@ +#!/usr/bin/env python +"""Install file for example on how to use Pyrex with Numpy. + +For more details, see: +http://www.scipy.org/Cookbook/Pyrex_and_NumPy +http://www.scipy.org/Cookbook/ArrayStruct_and_Pyrex +""" + +from distutils.core import setup +from distutils.extension import Extension + +# Make this usable by people who don't have pyrex installed (I've committed +# the generated C sources to SVN). +try: + from Pyrex.Distutils import build_ext + has_pyrex = True +except ImportError: + has_pyrex = False + +import numpy + +# Define a pyrex-based extension module, using the generated sources if pyrex +# is not available. +if has_pyrex: + pyx_sources = ['numpyx.pyx'] + cmdclass = {'build_ext': build_ext} +else: + pyx_sources = ['numpyx.c'] + cmdclass = {} + + +pyx_ext = Extension('numpyx', + pyx_sources, + include_dirs = [numpy.get_numpy_include()]) + +# Call the routine which does the real work +setup(name = 'numpyx', + description = 'Small example on using Pyrex to write a Numpy extension', + url = 'http://www.scipy.org/Cookbook/Pyrex_and_NumPy', + ext_modules = [pyx_ext], + cmdclass = cmdclass, + ) diff --git a/numpy/doc/swig/HelperFunctions.txt b/numpy/doc/swig/HelperFunctions.txt new file mode 100644 index 000000000..f195d29df --- /dev/null +++ b/numpy/doc/swig/HelperFunctions.txt @@ -0,0 +1,104 @@ +/*********************************************************************** + Helper functions from numpy.i, translated by John Hunter +************************************************************************/ + +#define is_array(a) ((a) && PyArray_Check((PyArrayObject *)a)) +#define array_type(a) (int)(((PyArrayObject *)a)->descr->type_num) +#define array_dimensions(a) (((PyArrayObject *)a)->nd) +#define array_size(a,i) (((PyArrayObject *)a)->dimensions[i]) +#define array_is_contiguous(a) (PyArray_ISCONTIGUOUS(a)) + +/* Given a PyObject, return a string describing its type. + */ +char* pytype_string(PyObject* py_obj) + +/* Given a Numeric typecode, return a string describing the type. + */ +char* typecode_string(int typecode) + +/* Make sure input has correct numeric type. Allow character and byte + * to match. Also allow int and long to match. + */ +int type_match(int actual_type, int desired_type) + +/* Given a PyObject pointer, cast it to a PyArrayObject pointer if + * legal. If not, set the python error string appropriately and + * return NULL. + */ +PyArrayObject* obj_to_array_no_conversion(PyObject* input, int typecode) + +/* Convert the given PyObject to a Numeric array with the given + * typecode. On Success, return a valid PyArrayObject* with the + * correct type. On failure, the python error string will be set and + * the routine returns NULL. + */ +PyArrayObject* obj_to_array_allow_conversion(PyObject* input, int typecode, + int* is_new_object) + +/* Given a PyArrayObject, check to see if it is contiguous. If so, + * return the input pointer and flag it as not a new object. If it is + * not contiguous, create a new PyArrayObject using the original data, + * flag it as a new object and return the pointer. + */ +PyArrayObject* make_contiguous(PyArrayObject* ary, int* is_new_object, + int min_dims, int max_dims) + +/* Convert a given PyObject to a contiguous PyArrayObject of the + * specified type. If the input object is not a contiguous + * PyArrayObject, a new one will be created and the new object flag + * will be set. + */ +PyArrayObject* obj_to_array_contiguous_allow_conversion(PyObject* input, + int typecode, + int* is_new_object) + +/* Test whether a python object is contiguous. If array is + * contiguous, return 1. Otherwise, set the python error string and + * return 0. + */ +int require_contiguous(PyArrayObject* ary) + +/* Require the given PyArrayObject to have a specified number of + * dimensions. If the array has the specified number of dimensions, + * return 1. Otherwise, set the python error string and return 0. + */ +int require_dimensions(PyArrayObject* ary, int exact_dimensions) + +/* Require the given PyArrayObject to have one of a list of specified + * number of dimensions. If the array has one of the specified number + * of dimensions, return 1. Otherwise, set the python error string + * and return 0. + */ +int require_dimensions_n(PyArrayObject* ary, int* exact_dimensions, int n) + +/* Require the given PyArrayObject to have a specified shape. If the + * array has the specified shape, return 1. Otherwise, set the python + * error string and return 0. + */ +int require_size(PyArrayObject* ary, int* size, int n) + +/*********************************************************************** + Helper functions from Anna Omelchenko and Michel Sanner +************************************************************************/ + +/******************************************************************** + The following function tries to create a contiguous numeric array of type + typecode from a Python object. Works for list, tuples and numeric arrays. + + obj: Numeric array , Python object + typecode: data type PyArray_{ CHAR, UBYTE, SBYTE, SHORT, INT, LONG, FLOAT, + DOUBLE, CFLOAT, CDOUBLE } + expectnd: required number of dimensions. Used for checking. Ignored if <=0. + expectdims: array of expected extends. Used for checking. Ignored if <=0. + + Raises ValueError exceptions if: + - the PyArray_ContiguousFromObject fails + - the array has a bad shape + - the extent of a given dimension doesn't match the specified extent. +If obj is a contiguous PyArrayObject then a reference is returned; +If op is PyObject sequence object(list, tuple) then a new PyArrayObject is created + and returned. +********************************************************************/ + +static PyArrayObject *contiguous_typed_array(PyObject *obj, int typecode, + int expectnd, int *expectdims) diff --git a/numpy/doc/swig/Makefile b/numpy/doc/swig/Makefile new file mode 100644 index 000000000..4469dc608 --- /dev/null +++ b/numpy/doc/swig/Makefile @@ -0,0 +1,14 @@ +INTERFACES = Series.i +WRAPPERS = $(INTERFACES:.i=_wrap.cxx) +PROXIES = $(INTERFACES:.i=.py ) + +all: $(WRAPPERS) series.cxx series.h + ./setup.py build + +%_wrap.cxx: %.i numpy.i series.h + swig -c++ -python $< + +clean: + $(RM) -r build + $(RM) $(WRAPPERS) + $(RM) $(PROXIES) diff --git a/numpy/doc/swig/README b/numpy/doc/swig/README new file mode 100644 index 000000000..494da98ba --- /dev/null +++ b/numpy/doc/swig/README @@ -0,0 +1,122 @@ +Notes for the swig_numpy/new directory +====================================== + +This set of files is for developing and testing file numpy.i, which +is intended to be a set of typemaps for helping SWIG interface between +C and C++ code that uses C arrays and the python module Numeric (also +known informally as NumPy, also to be replaced in the future with +scipy_core). It is ultimately hoped that numpy.i will be included +as part of the SWIG and/or SciPy distribution(s). + +In the spirit of "writing your tests first", I will begin by +describing the tests, as they are a good example of what we are trying +to do with numpy.i. The files related to testing are + + series.h + series.cxx + testSeries.py + +The series.h header file contains prototypes for functions that +illustrate the wrapping issues we wish to address. Right now, this +consists of functions with argument signatures of the form + + (type* IN_ARRAY1, int DIM1) + (type* IN_ARRAY2, int DIM1, int DIM2) + (type* INPLACE_ARRAY1, int DIM1) + +which take a pointer to an array of type "type", whose length is +specified by the integer(s) DIM1 (and DIM2). + +The objective for the IN_ARRAY signatures is for SWIG to generate +python wrappers that take a container that constitutes a valid +argument to the Numeric.array constructor, and can be used to build an +array of type "type". Currently, types "char", "unsigned char", +"signed char", "short", "int", "long", "float", "double" and +"PyObject" are supported, although only the types "short", "int", +"long", "float" and "double" are tested. + +The objective for the INPLACE_ARRAY signatures is for SWIG to generate +python wrappers that accept a Numeric array of any of the above-listed +types. + +The source file series.cxx contains the actual implementations of the +functions described in series.h. The python script testSeries.py +tests the resulting python wrappers using the unittest module. + +The SWIG interface file Series.i is used to generate the wrapper +code. It is pretty short, but everything in it is important. The +SWIG_FILE_WITH_INIT macro allows numpy.i to be used with multiple +python modules. If it is specified, then the %init block found in +Series.i is required. The other things done in Series.i are the +inclusion of the series.h and numpy.i files, and the "%apply" +directives to force the functions to use the typemaps. + +The setup.py script is a standard python distutils script. It defines +a _Series extension module and a Series python module. The Makefile +automates everything, setting up the dependencies, calling swig to +generate the wrappers, and calling setup.py to compile the wrapper +code and generate the shared object. Targets "all" (default) and +"clean" ar supported. + +To build and test the code, simply execute from the shell, + + $ make + $ testSeries.py + +================================================================================ + +ToDo +==== + + * Tests for the (INPLACE_ARRAY2, DIM1, DIM2) nedd to be added to + series.h, series.cxx and testSeries.py. + + * Support for complex data types should be added. Currently the + macro substitution doesn't seem to like the two words you need to + specify "complex double", etc. + + * ARGOUT typemaps need to be implemented and tested. I stalled on + this because SWIG implements a new method for aggregating output + arguments; it has changed from a tuple to a list and requires + importing a different SWIG library file. I didn't particularly + want to spend time trying to support both approaches, and I ended + up not finishing a typemap for either. + + +Notes Bill: + +The numpy.i file currently defines typemaps of the form + + (type* IN_ARRAY1, int DIM1) + (type* IN_ARRAY2, int DIM1, int DIM2) + (type* INPLACE_ARRAY1, int DIM1) + (type* INPLACE_ARRAY2, int DIM1, int DIM2) + +and has the beginnings of typemaps of the form + + (type* ARGOUT_ARRAY[ANY]) + (type* ARGOUT_ARRAY[ANY][ANY]) + +where "type" is almost any type supported by Numeric (I have had +trouble with complex), the "1" suffix can be used with any dimension +array as long as DIM1 reflects the total size, and the "2" suffix is +for explicitly 2-dimensional arrays. IN_ARRAYs can be any reasonable +container that can be used to construct a Numeric array. +INPLACE_ARRAYs must be Numeric arrays. + +I hit a snag with the ARGOUT typemaps, because the swig libraries have +changed and I did not know the best way to proceed. Basically, the old +way produced a tuple on the LHS if needed and the new way produces a +list. I forget why swig made the change, but the actual swig library +file you import changed because of it and I didn't feel like spending +time trying to support both approaches. + +So the ARGOUT typemaps need to be finished, functions that would use +them need to be added to series.{h,cxx} and tests for the resulting +python interface need to be added to testSeries.py. + +Most of the functions I deal with cannot use the ARGOUT typemaps +anyway, because they usually involve input arrays that share the same +dimension arguments as the output arrays, which will require a special +approach. So I don't have a lot of motivation there . . . but it +definitely needs to be done before any kind of release. diff --git a/numpy/doc/swig/Series.i b/numpy/doc/swig/Series.i new file mode 100644 index 000000000..8265dd35d --- /dev/null +++ b/numpy/doc/swig/Series.i @@ -0,0 +1,31 @@ +%module Series + +%{ +#define SWIG_FILE_WITH_INIT +#include "series.h" +%} + +// Get the Numeric typemaps +%include "numpy.i" + +%init %{ + import_array(); +%} + +// Apply the Numeric typemaps for 1D input arrays +%apply (short* IN_ARRAY1, int DIM1) {(short* series, int size)}; +%apply (int* IN_ARRAY1, int DIM1) {(int* series, int size)}; +%apply (long* IN_ARRAY1, int DIM1) {(long* series, int size)}; +%apply (float* IN_ARRAY1, int DIM1) {(float* series, int size)}; +%apply (double* IN_ARRAY1, int DIM1) {(double* series, int size)}; + +// Apply the Numeric typemaps for 2D input arrays +%apply (int* IN_ARRAY2, int DIM1, int DIM2) {(int* matrix, int rows, int cols)}; +%apply (double* IN_ARRAY2, int DIM1, int DIM2) {(double* matrix, int rows, int cols)}; + +// Apply the Numeric typemaps for 1D input/output arrays +%apply (int* INPLACE_ARRAY1, int DIM1) {(int* array, int size)}; +%apply (double* INPLACE_ARRAY1, int DIM1) {(double* array, int size)}; + +// Include the header file to be wrapped +%include "series.h" diff --git a/numpy/doc/swig/series.cxx b/numpy/doc/swig/series.cxx new file mode 100644 index 000000000..7c1e5f049 --- /dev/null +++ b/numpy/doc/swig/series.cxx @@ -0,0 +1,145 @@ +#include <stdlib.h> +#include <math.h> +#include <iostream> +#include "series.h" + +// *** One Dimensional Arrays *** + +// Functions that take 1D arrays of type SHORT as input +short shortSum(short* series, int size) { + short result = 0; + for (int i=0; i<size; ++i) result += series[i]; + return result; +} + +short shortProd(short* series, int size) { + short result = 1; + for (int i=0; i<size; ++i) result *= series[i]; + return result; +} + +// Functions that take 1D arrays of type INT as input +int intSum(int* series, int size) { + int result = 0; + for (int i=0; i<size; ++i) result += series[i]; + return result; +} + +int intProd(int* series, int size) { + int result = 1; + for (int i=0; i<size; ++i) result *= series[i]; + return result; +} + +// Functions that take 1D arrays of type LONG as input +long longSum(long* series, int size) { + long result = 0; + for (int i=0; i<size; ++i) result += series[i]; + return result; +} + +long longProd(long* series, int size) { + long result = 1; + for (int i=0; i<size; ++i) result *= series[i]; + return result; +} + +// Functions that take 1D arrays of type FLOAT as input +float floatSum(float* series, int size) { + float result = 0.0; + for (int i=0; i<size; ++i) result += series[i]; + return result; +} + +float floatProd(float* series, int size) { + float result = 1.0; + for (int i=0; i<size; ++i) result *= series[i]; + return result; +} + +// Functions that take 1D arrays of type DOUBLE as input +double doubleSum(double* series, int size) { + double result = 0.0; + for (int i=0; i<size; ++i) result += series[i]; + return result; +} + +double doubleProd(double* series, int size) { + double result = 1.0; + for (int i=0; i<size; ++i) result *= series[i]; + return result; +} + +// Functions that manipulate 1D arrays of type INT in-place +void intZeros(int* array, int size) { + for (int i=0; i<size; ++i) array[i] = 0; +} + +void intOnes(int* array, int size) { + for (int i=0; i<size; ++i) array[i] = 1; +} + +void intNegate(int* array, int size) { + for (int i=0; i<size; ++i) array[i] *= -1; +} + +// Functions that manipulate 1D arrays of type DOUBLE in-place +void doubleZeros(double* array, int size) { + for (int i=0; i<size; ++i) array[i] = 0.0; +} + +void doubleOnes(double* array, int size) { + for (int i=0; i<size; ++i) array[i] = 1.0; +} + +void doubleNegate(double* array, int size) { + for (int i=0; i<size; ++i) array[i] *= -1.0; +} + +// *** Two Dimensional Arrays *** + +// Functions that take 2D arrays of type INT as input +int intMax(int* matrix, int rows, int cols) { + int i, j, index; + int result = matrix[0]; + for (j=0; j<cols; ++j) { + for (i=0; i<rows; ++i) { + index = j*rows + i; + if (matrix[index] > result) result = matrix[index]; + } + } + return result; +} + +void intFloor(int* matrix, int rows, int cols, int floor) { + int i, j, index; + for (j=0; j<cols; ++j) { + for (i=0; i<rows; ++i) { + index = j*rows + i; + if (matrix[index] < floor) matrix[index] = 0; + } + } +} + +// Functions that take 2D arrays of type DOUBLE as input +double doubleMax(double* matrix, int rows, int cols) { + int i, j, index; + double result = matrix[0]; + for (j=0; j<cols; ++j) { + for (i=0; i<rows; ++i) { + index = j*rows + i; + if (matrix[index] > result) result = matrix[index]; + } + } + return result; +} + +void doubleFloor(double* matrix, int rows, int cols, double floor) { + int i, j, index; + for (j=0; j<cols; ++j) { + for (i=0; i<rows; ++i) { + index = j*rows + i; + if (matrix[index] < floor) matrix[index] = 0.0; + } + } +} diff --git a/numpy/doc/swig/series.h b/numpy/doc/swig/series.h new file mode 100644 index 000000000..f1b788c1b --- /dev/null +++ b/numpy/doc/swig/series.h @@ -0,0 +1,40 @@ +#ifndef SERIES_H +#define SERIES_H + +/*** One Dimensional Arrays ***/ + +/* Examples of functions that take 1D C arrays as input */ +short shortSum( short* series, int size); +short shortProd(short* series, int size); + +int intSum( int* series, int size); +int intProd(int* series, int size); + +long longSum( long* series, int size); +long longProd(long* series, int size); + +float floatSum( float* series, int size); +float floatProd(float* series, int size); + +double doubleSum( double* series, int size); +double doubleProd(double* series, int size); + +/* Examples of functions that manipulate 1D C arrays as in-place */ +void intZeros( int* array, int size); +void intOnes( int* array, int size); +void intNegate(int* array, int size); + +void doubleZeros( double* array, int size); +void doubleOnes( double* array, int size); +void doubleNegate(double* array, int size); + +/*** Two Dimensional Arrays ***/ + +/* Examples of functions that take 2D arrays as input */ +int intMax(int* matrix, int rows, int cols); +void intFloor(int* matrix, int rows, int cols, int floor); + +double doubleMax(double* matrix, int rows, int cols); +void doubleFloor(double* matrix, int rows, int cols, double floor); + +#endif diff --git a/numpy/doc/swig/setup.py b/numpy/doc/swig/setup.py new file mode 100755 index 000000000..4bf842c1f --- /dev/null +++ b/numpy/doc/swig/setup.py @@ -0,0 +1,24 @@ +#! /usr/bin/env python + +# System imports +from distutils.core import * +from distutils import sysconfig + +# Third-party modules - we depend on numpy for everything +import numpy + +# _Series extension module +_Series = Extension("_Series", + ["Series_wrap.cxx", + "series.cxx"], + include_dirs = [numpy.get_numpy_include()], +# libraries = ["m"] + ) + +# Series setup +setup(name = "Series", + description = "Functions that work on series", + author = "Bill Spotz", + py_modules = ["Series"], + ext_modules = [_Series] + ) diff --git a/numpy/doc/swig/testSeries.py b/numpy/doc/swig/testSeries.py new file mode 100755 index 000000000..845f8ce2e --- /dev/null +++ b/numpy/doc/swig/testSeries.py @@ -0,0 +1,186 @@ +#! /usr/bin/env python + +# System imports +from distutils.util import get_platform +import os +import sys +import unittest + +import numpy as N + +# Add the distutils-generated build directory to the python search path and then +# import the extension module +libDir = "lib.%s-%s" % (get_platform(), sys.version[:3]) +sys.path.insert(0,os.path.join("build", libDir)) +import Series + +###################################################################### + +class SeriesTestCase(unittest.TestCase): + + ######################################################## + ### Test functions that take 1D arrays of type SHORT ### + def testShortSum(self): + "Test the shortSum function" + self.assertEquals(Series.shortSum([1,2,3,4]), 10) + + def testShortProd(self): + "Test the shortProd function" + self.assertEquals(Series.shortProd([1,2,3,4]), 24) + + ###################################################### + ### Test functions that take 1D arrays of type INT ### + def testIntSum(self): + "Test the intSum function" + self.assertEquals(Series.intSum([1,2,3,4]), 10) + + def testIntSumBadContainer(self): + "Test the intSum function with an invalid list" + self.assertRaises(TypeError, Series.intSum, [1,2,"junk"]) + + def testIntProd(self): + "Test the intProd function" + self.assertEquals(Series.intProd([1,2,3,4]), 24) + + def testIntProdNonContainer(self): + "Test the intProd function with None" + self.assertRaises(TypeError, Series.intProd, None) + + def testIntZeros(self): + "Test the intZeros function" + myArray = N.ones(5,'i') + Series.intZeros(myArray) + N.testing.assert_array_equal(myArray, N.array([0,0,0,0,0])) + + def testIntZerosNonArray(self): + "Test the intZeros function with an integer" + self.assertRaises(TypeError, Series.intZeros, 5) + + def testIntOnes(self): + "Test the intOnes function" + myArray = N.zeros(5,'i') + Series.intOnes(myArray) + N.testing.assert_array_equal(myArray, N.array([1,1,1,1,1])) + + def testIntNegate(self): + "Test the intNegate function" + myArray = N.arange(5,dtype='i') + Series.intNegate(myArray) + N.testing.assert_array_equal(myArray, N.array([0,-1,-2,-3,-4])) + + ####################################################### + ### Test functions that take 1D arrays of type LONG ### + def testLongSum(self): + "Test the longSum function" + self.assertEquals(Series.longSum([1,2,3,4]), 10) + + def testLongSumMultiDimensional(self): + "Test the longSum function with multi-dimensional array" + self.assertRaises(TypeError, Series.longSum, [[1,2,3],[9,8,7]]) + + def testLongProd(self): + "Test the longProd function" + self.assertEquals(Series.longProd([1,2,3,4]), 24) + + ######################################################## + ### Test functions that take 1D arrays of type FLOAT ### + def testFloatSum(self): + "Test the floatSum function (to 5 decimal places)" + self.assertAlmostEquals(Series.floatSum([1,2,3.14,4]), 10.14, 5) + + def testFloatSumBadContainer(self): + "Test the floatSum function with a dictionary" + self.assertRaises(TypeError, Series.floatSum, {"key":"value"}) + + def testFloatProd(self): + "Test the floatProd function (to 5 decimal places)" + self.assertAlmostEquals(Series.floatProd((1,2.718,3,4)), 32.616, 5) + + def testFloatProdBadContainer(self): + "Test the floatProd function with an invalid list" + self.assertRaises(TypeError, Series.floatProd, [3.14, "pi"]) + + ######################################################### + ### Test functions that take 1D arrays of type DOUBLE ### + def testDoubleSum(self): + "Test the doubleSum function" + self.assertEquals(Series.doubleSum([1,2,3.14,4]), 10.14) + + def testDoubleSumNonContainer(self): + "Test the doubleSum function with None" + self.assertRaises(TypeError, Series.doubleSum, None) + + def testDoubleProd(self): + "Test the doubleProd function" + self.assertEquals(Series.doubleProd((1,2.718,3,4)), 32.616) + + def testDoubleProdBadContainer(self): + "Test the doubleProd function with an invalid list" + self.assertRaises(TypeError, Series.doubleProd, [3.14, "pi"]) + + def testDoubleZeros(self): + "Test the doubleZeros function" + myArray = N.ones(5,'d') + Series.doubleZeros(myArray) + N.testing.assert_array_equal(myArray, N.array([0.,0.,0.,0.,0.])) + + def testDoubleOnes(self): + "Test the doubleOnes function" + myArray = N.zeros(5,'d') + Series.doubleOnes(myArray) + N.testing.assert_array_equal(myArray, N.array([1.,1.,1.,1.,1.])) + + def testDoubleOnesNonArray(self): + "Test the doubleOnes function with a list" + self.assertRaises(TypeError, Series.doubleOnes, [True, 0, 2.718, "pi"]) + + def testDoubleNegate(self): + "Test the doubleNegate function" + myArray = N.arange(5) * 1.0 + Series.doubleNegate(myArray) + N.testing.assert_array_equal(myArray, N.array([0.,-1.,-2.,-3.,-4.])) + + ######################################################### + ### Test functions that take 2D arrays of type DOUBLE ### + def testIntMax(self): + "Test the intMax function" + matrix = [[6,-5,4],[-3,2,-1]] + self.assertEquals(Series.intMax(matrix), 6) + + def testIntMaxNonContainer(self): + "Test the intMax function with None" + self.assertRaises(TypeError, Series.intMax, None) + + def testIntFloor(self): + "Test the intFloor function" + matrix = N.array([[10,-2],[-6,7]]) + Series.intFloor(matrix,0) + N.testing.assert_array_equal(matrix, N.array([[10,0],[0,7]])) + + def testDoubleMax(self): + "Test the doubleMax function" + matrix = [[-6,5,-4],[3.14,-2.718,1]] + self.assertEquals(Series.doubleMax(matrix), 5.0) + + def testDoubleMaxWrongDim(self): + "Test the doubleMax function with a 1D array" + self.assertRaises(TypeError, Series.doubleMax, [0.0, -1, 2.718, -3.14]) + + def testDoubleFloor(self): + "Test the doubleFloor function" + matrix = N.array([[10,-2.718],[-6,3.14]]) + Series.doubleFloor(matrix,5.0) + N.testing.assert_array_equal(matrix, N.array([[10.0,0],[0,0]])) + +###################################################################### + +if __name__ == "__main__": + + # Build the test suite + suite = unittest.TestSuite() + suite.addTest(unittest.makeSuite(SeriesTestCase)) + + # Execute the test suite + print "Testing Module Series\n" + result = unittest.TextTestRunner(verbosity=2).run(suite) + sys.exit(len(result.errors) + len(result.failures)) |
