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/doc/pyrex | |
parent | 22335be3938621d9a4ed0ca0ac8ec5a8fc5a1da3 (diff) | |
download | numpy-7afda6a7aa249f3bfe490e62f61480d9e5e9c941.tar.gz |
Add rest of the examples for pyrex and swig
Diffstat (limited to 'numpy/doc/pyrex')
-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 |
8 files changed, 1214 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, + ) |